Tracing only supports a single context propagation type#35611
Conversation
...main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java
Outdated
Show resolved
Hide resolved
...main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java
Outdated
Show resolved
Hide resolved
...main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java
Outdated
Show resolved
Hide resolved
c5ef27d to
7070de0
Compare
da15179 to
4dd3d42
Compare
|
It works for both Brave and Otel now, build is green too. |
.../src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/TracingProperties.java
Outdated
Show resolved
Hide resolved
a3da5b1 to
532227d
Compare
|
When merging into 3.1.x, the test Stream.concat(injectorFactories.stream(), extractorFactories.stream()).allMatch(Factory::supportsJoin);Is that just an unfortunate consequence because we now apply all extractors, or is the span joining feature just for injecting and the @jonatan-ivanov As you implemented the test / feature, maybe you have an idea? If that's an unfortunate consequence and can't be changed, do we need a way to opt out of extracting all known formats? With that, users could configure B3 only for injecting and extracting, and span joining works again. Maybe by adding a property |
|
Yeah, if we consume all formats by default |
a0e5e2a to
a2796f1
Compare
|
No worries Jonatan. I've now added properties to control which formats we produce, which we accept and the
With that in place, we should have enough flexibility in our tracing setup. And users still have one property |
Alternative names for these properties to consider:
|
|
I've settled on |
|
And it's a merge! Thank you all for providing input! |
This change adds support for multiple context propagation types (e.g. B3 and W3C). It also adds support for a new propagation type,
B3_MULTI(which is B3 with multiple headers instead of the singleb3header).There are now two new properties:
management.tracing.propagation.consumewhich controls which trace formats the application will understand on incoming requests. It defaults to all known trace formats (W3C, B3 single, B3 multi).management.tracing.propagation.producewhich controls which trace formats the application will add to outgoing requests. It defaults to W3C.The
management.tracing.propagation.typehas been changed fromPropagationTypetoList<PropagationType>and the default has been removed. If set, this will override bothmanagement.tracing.propagation.consumeandmanagement.tracing.propagation.produce.The formats have an ordering, meaning that if one of the extractors matches, the one after it are no longer considered. The default ordering is:
The
CompositePropagationFactoryis the main piece of code for Brave which knows how to extract and inject multiple formats. It's a copy from Sleuth, somewhat refactored.The
CompositeTextMapPropagatoris the main piece of code for OTel. It's somewhat more complicated than the Brave pendant as we need to support theBaggageTextMapPropagatorwhich must run always even if one of the extractors before it has already extracted the context.I also removed a
@ConditionalOnMissingBeanfor typeB3PropagatorandW3CTraceContextPropagator. This should be fine as it's not consistent anyway. In thebagagge = truecase those@ConditionalOnMissingBeanare not effective but the extractors are added unconditionally inw3cTextMapPropagatorWithBaggageandb3BaggageTextMapPropagator.Property examples
To only use B3 single, set
management.tracing.propagation.typetoB3To only use B3 multi, set
management.tracing.propagation.typetoB3_MULTITo only use W3C multi, set
management.tracing.propagation.typetoW3CTo produce B3 single and W3C and accept W3C, B3 single and multi, set
management.tracing.propagation.producetoB3,W3Candmanagement.tracing.propagation.consumetoB3,B3_MULTI,W3CSee gh-35096