Skip to content

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

Closed
@ilya40umov

Description

@ilya40umov

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).

Activity

marcingrzejszczak

marcingrzejszczak commented on Dec 8, 2023

@marcingrzejszczak
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?

github-actions

github-actions commented on Dec 15, 2023

@github-actions
nmadhavi33

nmadhavi33 commented on Dec 15, 2023

@nmadhavi33

@ilya40umov did you get solution for above issue?

marcingrzejszczak

marcingrzejszczak commented on Dec 18, 2023

@marcingrzejszczak
Contributor

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

added this to the 1.x milestone on May 6, 2024
added a commit that references this issue on May 7, 2024
7c5d17f

5 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Propagating values from Observation.Context to Trace's Baggage · Issue #455 · micrometer-metrics/tracing