Struct opentelemetry::trace::SpanContext
source · pub struct SpanContext { /* private fields */ }
Expand description
Immutable portion of a Span
which can be serialized and propagated.
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 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. Currently, the only option is a boolean sampled flag.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns a bool flag which is true if the SpanContext
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 SpanContext
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
Returns the context’s TraceState
.
Trait Implementations§
source§impl Clone for SpanContext
impl Clone for SpanContext
source§fn clone(&self) -> SpanContext
fn clone(&self) -> SpanContext
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SpanContext
impl Debug for SpanContext
source§impl<'de> Deserialize<'de> for SpanContext
impl<'de> Deserialize<'de> for SpanContext
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for SpanContext
impl Hash for SpanContext
source§impl PartialEq for SpanContext
impl PartialEq for SpanContext
source§fn eq(&self, other: &SpanContext) -> bool
fn eq(&self, other: &SpanContext) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for SpanContext
impl Serialize for SpanContext
impl Eq for SpanContext
impl StructuralEq for SpanContext
impl StructuralPartialEq for SpanContext
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more