pub struct TraceContext { /* private fields */ }
Expand description
Trace context that is propagated through HTTP headers to enable distributed tracing.
Currently still missing support for tracestate, otherwise compliant with https://www.w3.org/TR/trace-context-2/#design-overview, which standardizes how context information is sent and modified between services.
Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn new(
trace_id: u128,
span_id: u64,
sampled: bool,
state: Option<String>,
) -> Self
pub fn new( trace_id: u128, span_id: u64, sampled: bool, state: Option<String>, ) -> Self
Construct a new trace context.
Version 0 of the trace context specification only supports the sampled
flag,
so we can offer a bool input for this flag.
Sourcepub fn new_sampled(trace_id: u128, span_id: u64, state: Option<String>) -> Self
pub fn new_sampled(trace_id: u128, span_id: u64, state: Option<String>) -> Self
Construct a new trace context with the sampled
flag set to true.
Sourcepub fn new_unsampled(
trace_id: u128,
span_id: u64,
state: Option<String>,
) -> Self
pub fn new_unsampled( trace_id: u128, span_id: u64, state: Option<String>, ) -> Self
Construct a new trace context with the sampled
flag set to false.
Sourcepub fn as_w3c_headers(&self) -> impl Iterator<Item = (&'static str, String)>
pub fn as_w3c_headers(&self) -> impl Iterator<Item = (&'static str, String)>
Render the context as w3c trace context headers.
Trait Implementations§
Source§impl Clone for TraceContext
impl Clone for TraceContext
Source§fn clone(&self) -> TraceContext
fn clone(&self) -> TraceContext
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Hash for TraceContext
impl Hash for TraceContext
Source§impl PartialEq for TraceContext
impl PartialEq for TraceContext
impl Eq for TraceContext
impl StructuralPartialEq for TraceContext
Auto Trait Implementations§
impl Freeze for TraceContext
impl RefUnwindSafe for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnwindSafe for TraceContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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>
Converts
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>
Converts
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 more