Function opentelemetry::global::get_text_map_propagator
source · pub fn get_text_map_propagator<T, F>(f: F) -> Twhere
F: FnMut(&dyn TextMapPropagator) -> T,
Expand description
Executes a closure with a reference to the current global TextMapPropagator
propagator.
Examples
use opentelemetry::{propagation::TextMapPropagator, global};
use opentelemetry::sdk::propagation::TraceContextPropagator;
use std::collections::HashMap;
let example_carrier = HashMap::new();
// create your text map propagator
let tc_propagator = TraceContextPropagator::new();
global::set_text_map_propagator(tc_propagator);
// use the global text map propagator to extract contexts
let _cx = global::get_text_map_propagator(|propagator| propagator.extract(&example_carrier));