spring-cloud-sleuth icon indicating copy to clipboard operation
spring-cloud-sleuth copied to clipboard

W3C baggage extraction fails when traceparent header not present

Open jamesmoessis opened this issue 1 year ago • 3 comments

Describe the bug We need the baggage header to be extracted whether there is a traceparent header or not.

Sample I've written a branch here: https://github.com/jamesmoessis/spring-cloud-sleuth/tree/showcase-issue

The sample sleuth application can be run and called by the testing.http file.

We are looking into possible solutions here since this is quite critical for us. We would appreciate some advice into how a solution might look for this. The problem is without a traceparent, there is no context to attach a baggage to. Is there a nice solution to this problem?

jamesmoessis avatar Jul 26 '22 02:07 jamesmoessis

Why would the baggage be propagated if there's no tracing context in the first place?

marcingrzejszczak avatar Aug 16 '22 12:08 marcingrzejszczak

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Aug 23 '22 12:08 spring-cloud-issues

The w3c baggage header specification doesn't mention a tracing context specifically, but rather states that libraries should propagate the baggage header downstream. In our case we want to propagate tenancy information, which is completely unrelated to tracing.

I don't actually know whether Sleuth would be the right place to implement this logic, given the aim of the library is to handle distributed tracing. At the same time it seems somewhat fit to put the logic into it given it handles header propagation concerns already.

miruflin avatar Aug 29 '22 07:08 miruflin

I think this is related to https://github.com/spring-cloud/spring-cloud-sleuth/issues/2190 which is related to https://github.com/micrometer-metrics/tracing/pull/71/files . I will close #2208

marcingrzejszczak avatar Jan 11 '23 17:01 marcingrzejszczak

@marcingrzejszczak Can I suggest going forward the W3C trace context propagators and W3C baggage propagator should be two separate implementations of Propagation. They propagate independently of each other so there is no need to couple them together. This is indeed how OpenTelemetry implements it here and here, generally then tied together with a composite propagator.

jamesmoessis avatar Jan 12 '23 00:01 jamesmoessis

From the w3c spec, my understanding is Baggage is independent with Trace Context, Trace Context contains traceparent and tracestate, which means using tracestate if user wants to propagate something when traceparent(trace id, span id, trace flags) must present, using Baggage if user wants to propagate something regardless tracing is enabled. So, correct me if I am wrong, the implementation should support propagate Baggage propagation even traceparent not present.

wangzlei avatar Jun 02 '23 02:06 wangzlei

@wangzlei in newer implementations (Micrometer Tracing + Otel) this works now. Sleuth is deprecated.

jamesmoessis avatar Jun 05 '23 03:06 jamesmoessis

That's not how it works in Sleuth. It works like this only with Tracing and OTel as @jamesmoessis mentioned

marcingrzejszczak avatar Jun 23 '23 11:06 marcingrzejszczak