logo
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 Propagators, 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 Propagators 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

Create a Jaeger propagator

Create a Jaeger propagator with custom header name

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Properly encodes the values of the Context and injects them into the Injector. Read more

Retrieves encoded data using the provided [Extractor]. If no data for this format was retrieved OR if the retrieved data is invalid, then the given Context is returned. Read more

Returns iter of fields used by [TextMapPropagator] Read more

Properly encodes the values of the current Context and injects them into the Injector. Read more

Retrieves encoded data using the provided [Extractor]. If no data for this format was retrieved OR if the retrieved data is invalid, then the current Context is returned. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

Attaches the current Context to this type, returning a WithContext wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Wrap the input message T in a tonic::Request

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more