[][src]Struct opentelemetry::api::context::propagation::composite_propagator::HttpTextCompositePropagator

pub struct HttpTextCompositePropagator { /* fields omitted */ }

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]

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.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> FutureExt for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,