pub struct TraceContext {
pub trace_id: Uuid,
pub spanid: Uuid,
pub parent_spanid: Option<Uuid>,
pub trace_flags: u8,
pub baggage: HashMap<String, String>,
pub tracestate: Option<String>,
pub is_remote: bool,
}
Expand description
Trace context for distributed tracing (W3C Trace Context compatible)
Fields§
§trace_id: Uuid
Unique trace identifier (16 bytes for W3C compatibility)
spanid: Uuid
Span identifier within the trace (8 bytes for W3C compatibility)
parent_spanid: Option<Uuid>
Parent span identifier
trace_flags: u8
Trace flags for sampling decisions (8 bits)
baggage: HashMap<String, String>
Additional baggage for context propagation
tracestate: Option<String>
W3C trace state for vendor-specific data
is_remote: bool
Remote flag for distributed traces
Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn remote_child(&self) -> Self
pub fn remote_child(&self) -> Self
Create a remote child context (from another service)
Sourcepub const fn is_sampled(&self) -> bool
pub const fn is_sampled(&self) -> bool
Check if trace is sampled
Sourcepub fn with_baggage(self, key: String, value: String) -> Self
pub fn with_baggage(self, key: String, value: String) -> Self
Add baggage item
Sourcepub fn with_tracestate(self, tracestate: String) -> Self
pub fn with_tracestate(self, tracestate: String) -> Self
Set trace state
Sourcepub fn to_traceparent(&self) -> String
pub fn to_traceparent(&self) -> String
Create W3C traceparent header value
Sourcepub fn from_traceparent(header: &str) -> Result<Self, CoreError>
pub fn from_traceparent(header: &str) -> Result<Self, CoreError>
Sourcepub fn to_baggage(&self) -> Option<String>
pub fn to_baggage(&self) -> Option<String>
Create baggage header value
Sourcepub fn with_baggage_header(self, header: &str) -> Self
pub fn with_baggage_header(self, header: &str) -> Self
Parse baggage header
Trait Implementations§
Source§impl Clone for TraceContext
impl Clone for TraceContext
Source§fn clone(&self) -> TraceContext
fn clone(&self) -> TraceContext
Returns a duplicate 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 TraceContext
impl Debug for TraceContext
Source§impl Default for TraceContext
impl Default for TraceContext
Source§impl<'de> Deserialize<'de> for TraceContext
impl<'de> Deserialize<'de> for TraceContext
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
Auto Trait Implementations§
impl Freeze for TraceContext
impl RefUnwindSafe for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnwindSafe for TraceContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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