View Source otel_propagator_b3 (opentelemetry_api v1.2.2)
An implementation of otel_propagator_text_map
that injects and extracts trace context using the B3 specification from Zipkin.
Since trace_context
and baggage
are the two default propagators the global TextMap Propagators must be configured if B3 is to be used for propagation:
{text_map_propagators, [b3, baggage]},
To use B3 multi-header format use:
{text_map_propagators, [b3multi, baggage]},
CompositePropagator = otel_propagator_text_map_composite:create([b3, baggage]),
opentelemetry:set_text_map_propagator(CompositePropagator).
It is also possible to set a separate list of injectors or extractors. For example, if the service should extract B3 encoded context but you only want to inject context encoded with the W3C TraceContext format (maybe you have some services only supporting B3 that are making requests to your server but you have no reason to continue propagating in both formats when communicating to other services further down the stack). In that case you would instead set configuration like:
{text_map_extractors, [b3, trace_context, baggage]},
{text_map_injectors, [trace_context, baggage]},
Or using calls to opentelemetry
at runtime:
B3CompositePropagator = otel_propagator_text_map_composite:create([b3, trace_context, baggage]),
CompositePropagator = otel_propagator_text_map_composite:create([trace_context, baggage]),
opentelemetry:set_text_map_extractor(B3CompositePropagator),
opentelemetry:set_text_map_injector(CompositePropagator).
Link to this section Summary
Link to this section Functions
-spec extract(Context, Carrier, CarrierKeysFun, CarrierGetFun, Options) -> Context when Context :: otel_ctx:t(), Carrier :: otel_propagator:carrier(), CarrierKeysFun :: otel_propagator_text_map:carrier_keys(), CarrierGetFun :: otel_propagator_text_map:carrier_get(), Options :: otel_propagator_text_map:propagator_options().
-spec inject(Context, Carrier, CarrierSetFun, Options) -> Carrier when Context :: otel_ctx:t(), Carrier :: otel_propagator:carrier(), CarrierSetFun :: otel_propagator_text_map:carrier_set(), Options :: b3multi | b3single.