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

Validate expected Observation API call ordering on TestObservationRegistry #5239

Closed
bclozel opened this issue Jul 1, 2024 · 1 comment · Fixed by #5300
Closed

Validate expected Observation API call ordering on TestObservationRegistry #5239

bclozel opened this issue Jul 1, 2024 · 1 comment · Fixed by #5300

Comments

@bclozel
Copy link
Contributor

bclozel commented Jul 1, 2024

While working on a Spring Framework instrumentation problem, I have noticed that my instrumentation could in some cases call observation.stop() twice. This is not an intended usage and is considered as a bug in the instrumentation.

In production, calling stop() multiple times on an observation will result in calling observation handlers multiple times. In case of metrics, this will create duplicate records for the same observation (it will be counted twice). I have tried to replicate this case and test against it in my test suite, but failed to do that. Right now "micrometer-observation-test" allows to check whether an observation has been closed. In case of multiple stop() calls, I couldn't find a way to detect this case with the TestObservationRegistry.

I understand that introducing additional state checks in observations would likely create a performance degradation - testing this case would help instrumentations.

@bclozel bclozel changed the title Prevent duplicate stops on observations Test duplicate stops on observations Jul 1, 2024
@shakuzen shakuzen modified the milestones: 1.14.0-M1, 1.14.0-M2 Jul 2, 2024
jonatan-ivanov added a commit to jonatan-ivanov/micrometer that referenced this issue Jul 11, 2024
@jonatan-ivanov
Copy link
Member

@bclozel What do you think about something like this: #5300?

jonatan-ivanov added a commit to jonatan-ivanov/micrometer that referenced this issue Jul 12, 2024
@shakuzen shakuzen changed the title Test duplicate stops on observations Validate expected Observation API call ordering on TestObservationRegistry Aug 13, 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 a pull request may close this issue.

3 participants