Struct opentelemetry_jaeger::Propagator
source · pub struct Propagator { /* private fields */ }
Expand description
The Jaeger propagator propagates span contexts in Jaeger propagation format.
Cross-cutting concerns send their state to the next process using Propagator
s,
which are defined as objects used to read and write context data to and from messages
exchanged by the applications. Each concern creates a set of Propagator
s for every
supported Propagator
type.
Note that jaeger header can be set in http header or encoded as url.
Examples
// setup jaeger propagator
global::set_text_map_propagator(JaegerPropagator::default());
// You also can init propagator with custom header name
// global::set_text_map_propagator(JaegerPropagator::with_custom_header("my-custom-header"));
// before sending requests to downstream services.
let mut headers = std::collections::HashMap::new(); // replace by http header of the outgoing request
let caller_span = global::tracer("caller").start("say hello");
let cx = Context::current_with_span(caller_span);
global::get_text_map_propagator(|propagator| {
propagator.inject_context(&cx, &mut headers); // propagator serialize the tracing context
});
// Send the request..
// Receive the request sent above on the other service...
// setup jaeger propagator
global::set_text_map_propagator(JaegerPropagator::new());
// You also can init propagator with custom header name
// global::set_text_map_propagator(JaegerPropagator::with_custom_header("my-custom-header"));
let headers = std::collections::HashMap::new(); // replace this with http header map from incoming requests.
let parent_context = global::get_text_map_propagator(|propagator| {
propagator.extract(&headers)
});
// this span's parent span will be caller_span in send_request functions.
let receiver_span = global::tracer("receiver").start_with_context("hello", &parent_context);
Implementations§
source§impl Propagator
impl Propagator
sourcepub fn with_custom_header(custom_header_name: &'static str) -> Self
pub fn with_custom_header(custom_header_name: &'static str) -> Self
Create a Jaeger propagator with custom header name
sourcepub fn with_custom_header_and_baggage(
custom_header_name: &'static str,
custom_baggage_prefix: &'static str
) -> Self
pub fn with_custom_header_and_baggage( custom_header_name: &'static str, custom_baggage_prefix: &'static str ) -> Self
Create a Jaeger propagator with custom header name and baggage prefix
NOTE: it’s implicitly fallback to the default header names when the ane of provided custom_* is empty
Default header-name is uber-trace-id
and baggage-prefix is uberctx-
The format of serialized context and baggage’s stays unchanged and not depending
on provided header name and prefix.
Trait Implementations§
source§impl Clone for Propagator
impl Clone for Propagator
source§fn clone(&self) -> Propagator
fn clone(&self) -> Propagator
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Propagator
impl Debug for Propagator
source§impl Default for Propagator
impl Default for Propagator
source§impl TextMapPropagator for Propagator
impl TextMapPropagator for Propagator
source§fn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
fn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
source§fn extract_with_context(
&self,
cx: &Context,
extractor: &dyn Extractor
) -> Context
fn extract_with_context( &self, cx: &Context, extractor: &dyn Extractor ) -> Context
Extractor
]. If no data for this
format was retrieved OR if the retrieved data is invalid, then the given
Context
is returned.Auto Trait Implementations§
impl RefUnwindSafe for Propagator
impl Send for Propagator
impl Sync for Propagator
impl Unpin for Propagator
impl UnwindSafe for Propagator
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§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> 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> 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