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
sourceimpl 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
sourceimpl Clone for Propagator
impl Clone for Propagator
sourcefn clone(&self) -> Propagator
fn clone(&self) -> Propagator
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Propagator
impl Debug for Propagator
sourceimpl Default for Propagator
impl Default for Propagator
sourceimpl TextMapPropagator for Propagator
impl TextMapPropagator for Propagator
sourcefn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
fn inject_context(&self, cx: &Context, injector: &mut dyn Injector)
sourcefn extract_with_context(&self, cx: &Context, extractor: &dyn Extractor) -> Context
fn extract_with_context(&self, cx: &Context, extractor: &dyn Extractor) -> Context
fn inject(&self, injector: &mut dyn Injector)
fn inject(&self, injector: &mut dyn Injector)
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more