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.
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 multiplestop()
calls, I couldn't find a way to detect this case with theTestObservationRegistry
.I understand that introducing additional state checks in observations would likely create a performance degradation - testing this case would help instrumentations.