pub struct HeaderInjector<'a>(/* private fields */);
Expand description
Injects the TextMapPropagator
to propagate trace parent information
in HTTP headers.
This propagation is useful when consumers of the HTTP response want to link
up their span data with the data produced in the Tower Layer
.
A concrete usage example is available in the TraceService::call
implementation for TraceService
.
This is pretty much a copy-pasted version of the HeaderInjector
from
the opentelemetry_http
crate. However, we cannot use this crate, as it
uses an outdated version of the underlying http
crate.
Implementations§
Source§impl<'a> HeaderInjector<'a>
impl<'a> HeaderInjector<'a>
Sourcepub fn new(headers: &'a mut HeaderMap) -> Self
pub fn new(headers: &'a mut HeaderMap) -> Self
Create a new header injecttor from a mutable reference to [HeaderMap
].
Sourcepub fn inject_context(&mut self, cx: &Context)
pub fn inject_context(&mut self, cx: &Context)
Inject the TextMapPropagator
into the HTTP headers.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for HeaderInjector<'a>
impl<'a> RefUnwindSafe for HeaderInjector<'a>
impl<'a> Send for HeaderInjector<'a>
impl<'a> Sync for HeaderInjector<'a>
impl<'a> Unpin for HeaderInjector<'a>
impl<'a> !UnwindSafe for HeaderInjector<'a>
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
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>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Wrap the input message
T
in a tonic::Request