[−][src]Struct opentelemetry::api::context::propagation::composite_propagator::HttpTextCompositePropagator
A propagator that chains multiple HttpTextFormat
propagators together,
injecting or extracting by their respective HTTP header names.
Injection and extraction from this propagator will preserve the order of the injectors and extractors passed in during initialization.
Examples
use opentelemetry::api::*; use opentelemetry::sdk; use std::collections::HashMap; use opentelemetry::api::trace::b3_propagator::B3Encoding; // First create 1 or more propagators let b3_propagator = B3Propagator::with_encoding(B3Encoding::SingleHeader); let trace_context_propagator = TraceContextPropagator::new(); // Then create a composite propagator let composite_propagator = HttpTextCompositePropagator::new(vec![ Box::new(b3_propagator), Box::new(trace_context_propagator), ]); // Then for a given implementation of `Injector` let mut injector = HashMap::new(); // And a given span let example_span = sdk::Provider::default().get_tracer("example-component").start("span-name"); // with the current context, call inject to add the headers composite_propagator.inject_context(&Context::current_with_span(example_span), &mut injector); // The injector now has both `X-B3` and `traceparent` headers assert!(injector.get("b3").is_some()); assert!(injector.get("traceparent").is_some());
Implementations
impl HttpTextCompositePropagator
[src]
pub fn new(propagators: Vec<Box<dyn HttpTextFormat + Send + Sync>>) -> Self
[src]
Constructs a new propagator out of instances of HttpTextFormat
.
Trait Implementations
impl Debug for HttpTextCompositePropagator
[src]
impl HttpTextFormat for HttpTextCompositePropagator
[src]
fn inject_context(&self, context: &Context, injector: &mut dyn Injector)
[src]
Encodes the values of the Context
and injects them into the Injector
.
fn extract_with_context(
&self,
cx: &Context,
extractor: &dyn Extractor
) -> Context
[src]
&self,
cx: &Context,
extractor: &dyn Extractor
) -> Context
Retrieves encoded Context
information using the Extractor
. If no data was
retrieved OR if the retrieved data is invalid, then the current Context
is
returned.
fn inject(&self, injector: &mut dyn Injector)
[src]
fn extract(&self, extractor: &dyn Extractor) -> Context
[src]
Auto Trait Implementations
impl !RefUnwindSafe for HttpTextCompositePropagator
impl Send for HttpTextCompositePropagator
impl Sync for HttpTextCompositePropagator
impl Unpin for HttpTextCompositePropagator
impl !UnwindSafe for HttpTextCompositePropagator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> FutureExt for T
[src]
fn with_context(self, otel_cx: OpenTelemetryContext) -> WithContext<Self>ⓘNotable traits for WithContext<T>
impl<T: Future> Future for WithContext<T> type Output = T::Output;
[src]
Notable traits for WithContext<T>
impl<T: Future> Future for WithContext<T> type Output = T::Output;
fn with_current_context(self) -> WithContext<Self>ⓘNotable traits for WithContext<T>
impl<T: Future> Future for WithContext<T> type Output = T::Output;
[src]
Notable traits for WithContext<T>
impl<T: Future> Future for WithContext<T> type Output = T::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,