Class W3CPropagation
- All Implemented Interfaces:
brave.propagation.Propagation<String>
Implementation of the TraceContext propagation protocol. See w3c/distributed-tracing.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface brave.propagation.Propagation
brave.propagation.Propagation.Factory, brave.propagation.Propagation.Getter<R,
K>, brave.propagation.Propagation.KeyFactory<K>, brave.propagation.Propagation.RemoteGetter<R>, brave.propagation.Propagation.RemoteSetter<R>, brave.propagation.Propagation.Setter<R, K> -
Field Summary
Fields inherited from interface brave.propagation.Propagation
B3_SINGLE_STRING, B3_STRING
-
Constructor Summary
ConstructorDescriptionCreates an instance ofW3CPropagation
without baggage support.W3CPropagation
(io.micrometer.tracing.BaggageManager baggageManager, List<String> localFields) Creates an instance ofW3CPropagation
with baggage support. -
Method Summary
Methods inherited from class brave.propagation.Propagation.Factory
create, decorate, requires128BitTraceId, supportsJoin
-
Constructor Details
-
W3CPropagation
public W3CPropagation(io.micrometer.tracing.BaggageManager baggageManager, List<String> localFields) Creates an instance ofW3CPropagation
with baggage support.- Parameters:
baggageManager
- baggage managerlocalFields
- local fields to be registered as baggage
-
W3CPropagation
public W3CPropagation()Creates an instance ofW3CPropagation
without baggage support.
-
-
Method Details
-
get
- Overrides:
get
in classbrave.propagation.Propagation.Factory
-
keys
- Specified by:
keys
in interfacebrave.propagation.Propagation<String>
-
injector
public <R> brave.propagation.TraceContext.Injector<R> injector(brave.propagation.Propagation.Setter<R, String> setter) - Specified by:
injector
in interfacebrave.propagation.Propagation<String>
-
extractor
public <R> brave.propagation.TraceContext.Extractor<R> extractor(brave.propagation.Propagation.Getter<R, String> getter) This does not set the shared flag when extracting headersTraceContext.shared()
is not set here because it is not a remote propagation field.shared
is a field in the Zipkin JSON v2 format only set after header extraction, forSpan.Kind.SERVER
spans implicitly viaTracer.joinSpan(TraceContext)
.Blindly setting
shared
regardless of this is harmful whenTracer.currentSpan()
or similar are used, as any data tagged with these could also set the shared flag when reporting. Particularly, this can cause problems for multi- Span.Kind.CONSUMER spans. Regardless, setting invalid flags add overhead.In summary, while
shared
is propagated in-process, it has never been propagated out of process, and so should never be set when extracting headers. Hence, this code will not setTraceContext.shared()
.- Specified by:
extractor
in interfacebrave.propagation.Propagation<String>
-