Struct opentelemetry::trace::SpanContext
source · 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 moresource§impl Debug for SpanContext
impl Debug for SpanContext
source§impl Hash for SpanContext
impl Hash for SpanContext
source§impl PartialEq for SpanContext
impl PartialEq for SpanContext
impl Eq for SpanContext
impl StructuralPartialEq for SpanContext
Auto Trait Implementations§
impl Freeze for SpanContext
impl RefUnwindSafe for SpanContext
impl Send for SpanContext
impl Sync for SpanContext
impl Unpin for SpanContext
impl UnwindSafe for SpanContext
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)