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

Propagating values from Observation.Context to Trace's Baggage #455

Closed
ilya40umov opened this issue Nov 23, 2023 · 4 comments · Fixed by #688
Closed

Propagating values from Observation.Context to Trace's Baggage #455

ilya40umov opened this issue Nov 23, 2023 · 4 comments · Fixed by #688
Labels
enhancement New feature or request feedback-provided question Further information is requested
Milestone

Comments

@ilya40umov
Copy link

When I first read about the new Observation API I somehow got an idea that key-value pairs that I would add to the context (e.g. via highCardinalityKeyValues/lowCardinalityKeyValues) would then be automatically set on the baggage fields that I registered (e.g. via management.tracing.baggage.correlation.fields). This would basically ensure that if I were to register a custom baggage field such as userId and report a value for this key in, say, the implementation of ObservationConvention in use, I would then be able to get this field easily in the MDC context and thus have it attached to all log records printed from within the observation.

After multiple attempts to make this work, I've checked the implementation of TracingObservationHandler.java and the only thing that is happening with the context key-value pairs is that they are used to tag the span.

Looking at the old Spring Sleuth docs, I see that there used to be spring.sleuth.baggage.tag-fields property that would allow to specify which tag fields should be added to baggage, but this is not available in Micrometer Tracing / current Spring Boot as far as I can tell.

Is this something that will be implement by Micrometer / Spring at some point or we should work on some work-arounds on our end?

P.S. Right now we kinda have to work with both Observation API (e.g. to avoid working with Trace/Span directly), and at the same time call tracer.createBaggageInScope to make sure custom attributes end up in the logs (via baggage to MDC propagation).

@marcingrzejszczak
Copy link
Contributor

The problem currently is that Observation has no notion of baggage. I'm kind of on the fence whether it should be publicly available in Micrometer Observation API. Any opinions @jonatan-ivanov @shakuzen @ttddyy ? I know that @chemicL was thinking that most likely Baggage should become the first class citizen of the Observation API, is it still correct?

@marcingrzejszczak marcingrzejszczak added the question Further information is requested label Dec 8, 2023

This comment was marked as outdated.

@nmadhavi33
Copy link

@ilya40umov did you get solution for above issue?

@marcingrzejszczak
Copy link
Contributor

This is still in progress. The feedback related labels were added by the bot that we are experimenting with

@marcingrzejszczak marcingrzejszczak added the enhancement New feature or request label May 6, 2024
@marcingrzejszczak marcingrzejszczak added this to the 1.x milestone May 6, 2024
marcingrzejszczak added a commit that referenced this issue May 7, 2024
whenever a key-value matches a preconfigured baggage config and an Observation started a scope then automatically baggages will also be started

fixes gh-455
marcingrzejszczak added a commit that referenced this issue May 20, 2024
whenever a key-value matches a preconfigured baggage config and an Observation started a scope then automatically baggages will also be started

fixes gh-455
@marcingrzejszczak marcingrzejszczak modified the milestones: 1.x, 1.4.0-M1 May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feedback-provided question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants