pub struct Traceparent { /* private fields */ }
Expand description
This type contains emit
’s TraceId
and SpanId
, along with TraceFlags
that determine sampling.
Traceparents exist at the edges of your application.
On incoming requests, it may carry a traceparent header that can be parsed into a Traceparent
and pushed onto the active trace context with Traceparent::push
.
On outgoing requests, the active trace context is pulled by Traceparent::current
and formatted into a traceparent header.
Implementations§
Source§impl Traceparent
impl Traceparent
Sourcepub const fn new(
trace_id: Option<TraceId>,
span_id: Option<SpanId>,
trace_flags: TraceFlags,
) -> Self
pub const fn new( trace_id: Option<TraceId>, span_id: Option<SpanId>, trace_flags: TraceFlags, ) -> Self
Create a new traceparent with the given trace id, span id, and trace flags.
Sourcepub fn try_from_str(traceparent: &str) -> Result<Self, Error>
pub fn try_from_str(traceparent: &str) -> Result<Self, Error>
Parse a traceparent from its text format, as defined in the W3C standard.
Sourcepub fn trace_flags(&self) -> &TraceFlags
pub fn trace_flags(&self) -> &TraceFlags
Get the trace flags.
These flags can be used to tell whether the traceparent is for a sampled trace or not.
Sourcepub fn current() -> Self
pub fn current() -> Self
Get the current trace context.
If no context has been set, this method will return a new traceparent with no trace id or span id, but with TraceFlags::SAMPLED
.
Sourcepub fn push(&self) -> Frame<TraceparentCtxt>
pub fn push(&self) -> Frame<TraceparentCtxt>
Get a Frame
that can set the current trace context in a scope.
While the frame is active, Traceparent::current
will return this traceparent.
Trait Implementations§
Source§impl Clone for Traceparent
impl Clone for Traceparent
Source§fn clone(&self) -> Traceparent
fn clone(&self) -> Traceparent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more