pub struct TextMapSplitPropagator { /* private fields */ }Expand description
A text map propagator that uses different propagators for injection and extraction.
This propagator allows for asymmetric context propagation where different propagation strategies can be used for outgoing requests (injection) versus incoming requests (extraction). This is useful when you need to maintain compatibility with multiple tracing systems or protocols.
§Use Cases
- Migrating between tracing systems while maintaining compatibility
- Supporting multiple trace context formats in a single service
- Using environment-specific propagation strategies
Implementations§
Source§impl TextMapSplitPropagator
impl TextMapSplitPropagator
Sourcepub fn new(
extract_propagator: Propagator,
inject_propagator: Propagator,
) -> Self
pub fn new( extract_propagator: Propagator, inject_propagator: Propagator, ) -> Self
Creates a new split propagator with separate propagators for extraction and injection.
§Arguments
extract_propagator: Propagator used for extracting context from incoming requestsinject_propagator: Propagator used for injecting context into outgoing requests
§Returns
A new TextMapSplitPropagator instance
Sourcepub fn from_env() -> Result<Self, TraceError>
pub fn from_env() -> Result<Self, TraceError>
Creates a split propagator based on the OTEL_PROPAGATORS environment variable.
This method reads the OTEL_PROPAGATORS environment variable to determine which
propagators to use. The first propagator in the list is used for injection,
while all propagators are composed together for extraction.
§Environment Variable Format
The OTEL_PROPAGATORS variable should contain a comma-separated list of propagator names:
tracecontext: W3C Trace Context propagatorbaggage: W3C Baggage propagatorb3: B3 single header propagator (requires “zipkin” feature)b3multi: B3 multiple header propagator (requires “zipkin” feature)xray: AWS X-Ray propagator (requires “xray” feature)none: No-op propagator
§Returns
A configured TextMapSplitPropagator on success, or a TraceError if
the environment variable contains unsupported propagator names.
§Examples
export OTEL_PROPAGATORS=tracecontext,baggageuse telemetry_rust::propagation::TextMapSplitPropagator;
let propagator = TextMapSplitPropagator::from_env()?;Trait Implementations§
Source§impl Debug for TextMapSplitPropagator
impl Debug for TextMapSplitPropagator
Source§impl Default for TextMapSplitPropagator
impl Default for TextMapSplitPropagator
Source§impl TextMapPropagator for TextMapSplitPropagator
impl TextMapPropagator for TextMapSplitPropagator
Source§fn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
fn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
Source§fn fields(&self) -> FieldIter<'_>
fn fields(&self) -> FieldIter<'_>
TextMapPropagatorAuto Trait Implementations§
impl Freeze for TextMapSplitPropagator
impl !RefUnwindSafe for TextMapSplitPropagator
impl Send for TextMapSplitPropagator
impl Sync for TextMapSplitPropagator
impl Unpin for TextMapSplitPropagator
impl !UnwindSafe for TextMapSplitPropagator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request