logback mdc baggage with root span #12548
Replies: 2 comments 5 replies
-
An alternative solution to my issue would be a way to add specific Span attributes to every log message further down the trace. So I can set a span attribute at some point and from that point on it will be included in every log message like an MDC, is this doable? In the end I am just looking for a way to set a field once and that field must be present in every log message. |
Beta Was this translation helpful? Give feedback.
-
For the added baggage to become visible you have to add it to context and then make that context current. In
The goal of that instrumentation is to expose trace_id, span_id, baggage values etc. so that they could be used in logging patterns. Exposing them in
Baggage is not tied to the span, it is a separate concept. When context propagation to an external service happens baggage propagator looks for the current baggage from the context and propagates it. |
Beta Was this translation helpful? Give feedback.
-
I am trying to add this Baggage to the context that is part of the local root span. My idea is that at some point in the service, I will have an ID that I want to place in the root span as baggage and I want to propagate it until the end of the trace. Is this achievable? I tried with something like:
but the next log messages do not have the baggage values as MDC.
It does work when I do it like this:
but only for one log message, the one in the try:
I am using
with spring boot opentelemetry starter
Also, I was expecting to be able to access the MDC values with MDC.get but the context map is empty.
Beta Was this translation helpful? Give feedback.
All reactions