Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a LongTaskTimer for every Observation in TimerObservationHandler #3215

Merged
merged 5 commits into from Jun 15, 2022

Conversation

jonatan-ivanov
Copy link
Member

@jonatan-ivanov jonatan-ivanov commented Jun 10, 2022

This PR changes the behavior of TimerObservationHandler so that it will always create an additional LongTaskTimer (on top of the Timer) so that the active task can be observed too on-the-fly.

There is a caveat/issue with this: since the KeyValuesProvider is used at stop, none of those tags will be added to the LongTaskTimer. Also, the tags that are added to the Observation after start won't be added to the LongTaskTimer.

/cc @cppwfs

This way handlers will be able to handle tasks that can potentially take long differently (e.g.: tracking active tasks while they are active)
@jonatan-ivanov jonatan-ivanov changed the title Signal long tasks on the Observation Add a LongTaskTimer for every Observation Jun 13, 2022
Copy link
Member

@shakuzen shakuzen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. I think it's worthwhile in most cases to have a LTT along with a Timer to see metrics on in-flight tasks. In theory, if something being timed has a timeout that's less than the step interval - meaning an active task would never be timed across two step intervals, then I guess the LTT becomes less interesting. As long as the overhead of the LTT isn't a problem, though, I think it is fine.

The difference in tags is a potential point of confusion. We should document it in the JavaDoc perhaps.

@jonatan-ivanov jonatan-ivanov added this to the 1.10.0-M3 milestone Jun 15, 2022
@shakuzen shakuzen merged commit 108efb3 into micrometer-metrics:main Jun 15, 2022
@shakuzen shakuzen added the module: micrometer-core An issue that is related to our core module label Jun 15, 2022
@jonatan-ivanov jonatan-ivanov deleted the long-task-signal branch June 15, 2022 04:17
.lowCardinalityKeyValue("staticTag", "42").start();

// created after start, LongTaskTimer won't have it
observation.lowCardinalityKeyValue("dynamicTag", "24");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general that shouldn't really happen. We will recommend to the users that they create a non started observation, and always use a key value provider (I think that in extremely rare cases they could set key value pairs manually)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KeyValueProvider is the same case since it is queried at stop when you have all the details in the context and the LongTaskTimer is created at start.

@shakuzen shakuzen changed the title Add a LongTaskTimer for every Observation Add a LongTaskTimer for every Observation in TimerObservationHandler Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement module: micrometer-core An issue that is related to our core module module: micrometer-observation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants