pub struct TracePropagationInterceptor;Expand description
Writes the ambient CurrentTrace onto each outbound request.
With no scope open it adds nothing, so a client used outside a traced
call is unaffected. It never overwrites a traceparent a caller set on
the request itself — an explicit header is a decision, and silently
replacing it would move the callee into a different trace than the one
its caller asked for.
That guard is case-insensitive, because the header name is.
W3C Trace Context §3.2.1 and §3.3.1 both say: “Vendors MUST expect the
header name in any case (upper, lower, mixed), and SHOULD send the header
name in lowercase.” A case-sensitive lookup against the lowercase literal
would miss a caller’s Traceparent and write a second one, and both HTTP
transports build the request with hyper::Request::builder().header(..),
which appends rather than replaces — so the peer would receive two
traceparent fields and pick whichever its own parser happened to.
One transport is outside its reach, and says so in its own module docs:
WebSocketTransport (behind the websocket feature) cannot carry a
per-request header at all, so nothing this interceptor writes reaches the
wire on an established WebSocket connection.
Implementations§
Source§impl TracePropagationInterceptor
impl TracePropagationInterceptor
Sourcepub const fn new() -> TracePropagationInterceptor
pub const fn new() -> TracePropagationInterceptor
Creates the interceptor.
Trait Implementations§
Source§impl CallInterceptor for TracePropagationInterceptor
impl CallInterceptor for TracePropagationInterceptor
Source§fn before<'a>(
&'a self,
req: &'a mut ClientRequest,
) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
fn before<'a>( &'a self, req: &'a mut ClientRequest, ) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
Source§fn after<'a>(
&'a self,
_resp: &'a ClientResponse,
) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
fn after<'a>( &'a self, _resp: &'a ClientResponse, ) -> impl Future<Output = Result<(), ClientError>> + Send + 'a
Source§fn on_error<'a>(
&'a self,
req: &'a ClientRequest,
err: &'a ClientError,
) -> impl Future<Output = ()> + Send + 'a
fn on_error<'a>( &'a self, req: &'a ClientRequest, err: &'a ClientError, ) -> impl Future<Output = ()> + Send + 'a
before hooks saw, in reverse registration order like after. Read moreSource§impl Clone for TracePropagationInterceptor
impl Clone for TracePropagationInterceptor
Source§fn clone(&self) -> TracePropagationInterceptor
fn clone(&self) -> TracePropagationInterceptor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TracePropagationInterceptor
Source§impl Debug for TracePropagationInterceptor
impl Debug for TracePropagationInterceptor
Source§impl Default for TracePropagationInterceptor
impl Default for TracePropagationInterceptor
Source§fn default() -> TracePropagationInterceptor
fn default() -> TracePropagationInterceptor
Auto Trait Implementations§
impl Freeze for TracePropagationInterceptor
impl RefUnwindSafe for TracePropagationInterceptor
impl Send for TracePropagationInterceptor
impl Sync for TracePropagationInterceptor
impl Unpin for TracePropagationInterceptor
impl UnsafeUnpin for TracePropagationInterceptor
impl UnwindSafe for TracePropagationInterceptor
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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