#[non_exhaustive]pub struct TraceContext {
pub trace_id: Vec<u8>,
pub span_id: Vec<u8>,
pub trace_flags: u8,
}Expand description
OTel-style trace context extracted from the current span.
Returned by current_trace_context for propagation into outbound
HTTP calls (W3C traceparent header). The IDs are kept as opaque bytes so
this type does not leak a specific OTel SDK version into the ABI crate; use
TraceContext::to_traceparent to render the wire form.
#[non_exhaustive] so future fields (e.g. tracestate) can be added
without breaking downstream struct-literal construction.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.trace_id: Vec<u8>Trace identifier (16 bytes when populated, empty otherwise).
span_id: Vec<u8>Span identifier (8 bytes when populated, empty otherwise).
trace_flags: u8W3C trace flags (bit 0 = sampled). Zero when no context is present.
Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn to_traceparent(&self) -> Option<String>
pub fn to_traceparent(&self) -> Option<String>
Render the context as a W3C traceparent header value.
Returns None unless both IDs are present and correctly sized — i.e.
there is a real context to propagate. The format is
00-<32 hex trace-id>-<16 hex span-id>-<2 hex flags>.
Trait Implementations§
Source§impl Clone for TraceContext
impl Clone for TraceContext
Source§fn clone(&self) -> TraceContext
fn clone(&self) -> TraceContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TraceContext
impl Debug for TraceContext
Source§impl Default for TraceContext
impl Default for TraceContext
Source§fn default() -> TraceContext
fn default() -> TraceContext
Auto Trait Implementations§
impl Freeze for TraceContext
impl RefUnwindSafe for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnsafeUnpin for TraceContext
impl UnwindSafe for TraceContext
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more