Struct opentelemetry_api::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 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 From<&SpanContext> for TraceContext
impl From<&SpanContext> for TraceContext
source§fn from(span_context: &SpanContext) -> Self
fn from(span_context: &SpanContext) -> Self
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
self
and other
values to be equal, and is used
by ==
.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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.