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 history-tracking to ObservationValidator #5370

Merged

Conversation

jonatan-ivanov
Copy link
Member

@jonatan-ivanov jonatan-ivanov commented Aug 8, 2024

This change lets you peek into the history of certain interactions with your Observations if an InvalidObservationException is thrown. This includes which method was called on your Observations (start, stop, error, etc) and also the relevant part of the stack trace. This is helpful when the instrumentation is complex and it is not apparent where a previous call to Observation happened that needs to be fixed.

InvalidObservationException can provide you the full history through its getHistory method and it also gives you a summary through its toString, something like this:

io.micrometer.observation.tck.InvalidObservationException: Invalid error signal: Observation has already been stopped
START: app//io.micrometer.observation.tck.ObservationValidatorTests.errorAfterStopShouldBeInvalid(ObservationValidatorTests.java:98)
STOP: app//io.micrometer.observation.tck.ObservationValidatorTests.errorAfterStopShouldBeInvalid(ObservationValidatorTests.java:99)
ERROR: app//io.micrometer.observation.tck.ObservationValidatorTests.errorAfterStopShouldBeInvalid(ObservationValidatorTests.java:100)

This change lets you peek into the history of certain interactions with
your Observations if an InvalidObservationException is thrown.
This includes which method was called on your Observations
(start, stop, error, etc) and also the relevant part of the stack trace.

InvalidObservationException can provide you the full history through its
getHistory method and it also gives you a summary through its toString.
@jonatan-ivanov jonatan-ivanov added the enhancement A general enhancement label Aug 8, 2024
@jonatan-ivanov jonatan-ivanov added this to the 1.14.0-M2 milestone Aug 8, 2024
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.

Looks great. This will be very helpful in more quickly tracking down instrumentation issues, especially if the IDE makes the class name + line number a link to the exact line of code where the Observation calls were made.

@shakuzen shakuzen merged commit 3d26472 into micrometer-metrics:main Aug 8, 2024
6 checks passed
@jonatan-ivanov jonatan-ivanov deleted the observation-history branch August 8, 2024 17:49
@izeye izeye mentioned this pull request Oct 19, 2024
jonatan-ivanov pushed a commit that referenced this pull request Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants