pub struct SpanContext { /* private fields */ }
Expand description
Immutable portion of a Span
which can be serialized and propagated.
This representation conforms to the W3C TraceContext specification.
Spans that do not have the sampled
flag set in their TraceFlags
will
be ignored by most tracing tools.
Implementations§
Source§impl SpanContext
impl SpanContext
Sourcepub const NONE: SpanContext = _
pub const NONE: SpanContext = _
An invalid span context
Sourcepub fn empty_context() -> Self
pub fn empty_context() -> Self
Create an invalid empty span context
Sourcepub fn new(
trace_id: TraceId,
span_id: SpanId,
trace_flags: TraceFlags,
is_remote: bool,
trace_state: TraceState,
) -> Self
pub fn new( trace_id: TraceId, span_id: SpanId, trace_flags: TraceFlags, is_remote: bool, trace_state: TraceState, ) -> Self
Construct a new SpanContext
Sourcepub fn trace_flags(&self) -> TraceFlags
pub fn trace_flags(&self) -> TraceFlags
Returns details about the trace.
Unlike TraceState
values, these are present in all traces. The current
version of the specification only supports a single flag TraceFlags::SAMPLED
.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if the span context has a valid (non-zero) trace_id
and a
valid (non-zero) span_id
.
Sourcepub fn is_remote(&self) -> bool
pub fn is_remote(&self) -> bool
Returns true
if the span context was propagated from a remote parent.
Sourcepub fn is_sampled(&self) -> bool
pub fn is_sampled(&self) -> bool
Returns true
if the sampled
trace flag is set.
Spans that are not sampled will be ignored by most tracing tools.
Sourcepub fn trace_state(&self) -> &TraceState
pub fn trace_state(&self) -> &TraceState
A reference to the span context’s TraceState
.
Trait Implementations§
Source§impl Clone for SpanContext
impl Clone for SpanContext
Source§fn clone(&self) -> SpanContext
fn clone(&self) -> SpanContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more