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

ObservationValidator fails with NullObservation #5388

Closed
chemicL opened this issue Aug 14, 2024 · 1 comment · Fixed by #5389
Closed

ObservationValidator fails with NullObservation #5388

chemicL opened this issue Aug 14, 2024 · 1 comment · Fixed by #5389

Comments

@chemicL
Copy link

chemicL commented Aug 14, 2024

Describe the bug

When empty scopes are present thanks to NullObservation, the validation with ObservationValidator fails.

To Reproduce

micrometer-metrics/tracing#810

Expected behavior

NullObservation doesn't cause ObservationValidator to fail.

Additional context

The issue is that NullObservation doesn't launch handlers for most events (e.g. start) but it launches handlers for scope opening and closing events. Combined with ObservationValidator being implemented as a handler this always causes NullObservation to trigger a failure.

Ideas, notes

It is crucial that NullObservation doesn't do unnecessary work as it is often on the hot path in reactive chains.

Therefore, perhaps it's worth considering an alternative implementation only created at test runtime which fires up all handlers. That code would need to interact with ObservationThreadLocalAccessor.

Another idea would be to skip validation on NullObservation, e.g. by providing

context -> !"null".equals(context.getName())

as supportsContextPredicate argument to ObservationValidator.

jonatan-ivanov added a commit to jonatan-ivanov/micrometer that referenced this issue Aug 14, 2024
NullObservation is a special case for context propagation. It's not
fully an Observation since it is only for scope handling which can
happen outside of "normal" Observations, therefore we not necessarily
need to validate it.

Closes micrometer-metricsgh-5388
@shakuzen shakuzen added this to the 1.14.0-M3 milestone Aug 27, 2024
@shakuzen
Copy link
Member

A new NullContext was introduced to make the conditional less brittle for ignoring NullObservation in the ObservationValidator.

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.

2 participants