pub struct W3CTraceContext {
pub trace_id: String,
pub parent_id: String,
pub trace_flags: String,
pub trace_state: Option<String>,
}Expand description
W3C Trace Context implementation for distributed tracing
Fields§
§trace_id: StringW3C trace ID (32 hex characters)
parent_id: StringW3C span ID (16 hex characters)
trace_flags: StringTrace flags (2 hex characters)
trace_state: Option<String>Additional trace state
Implementations§
Source§impl W3CTraceContext
impl W3CTraceContext
Sourcepub fn from_traceparent(header: &str) -> ObservabilityResult<Self>
pub fn from_traceparent(header: &str) -> ObservabilityResult<Self>
Create from W3C traceparent header
Sourcepub fn from_headers(
headers: &HashMap<String, String>,
) -> ObservabilityResult<Option<Self>>
pub fn from_headers( headers: &HashMap<String, String>, ) -> ObservabilityResult<Option<Self>>
Create from W3C headers
Sourcepub fn to_traceparent(&self) -> String
pub fn to_traceparent(&self) -> String
Generate W3C traceparent header value
Sourcepub fn to_headers(&self) -> HashMap<String, String>
pub fn to_headers(&self) -> HashMap<String, String>
Generate W3C headers for propagation
Sourcepub fn is_sampled(&self) -> bool
pub fn is_sampled(&self) -> bool
Check if the trace is sampled
Sourcepub fn set_sampled(&mut self, sampled: bool)
pub fn set_sampled(&mut self, sampled: bool)
Set sampling flag
Sourcepub fn add_trace_state(&mut self, key: &str, value: &str)
pub fn add_trace_state(&mut self, key: &str, value: &str)
Add or update trace state
Sourcepub fn get_trace_state(&self, key: &str) -> Option<String>
pub fn get_trace_state(&self, key: &str) -> Option<String>
Get value from trace state
Trait Implementations§
Source§impl Clone for W3CTraceContext
impl Clone for W3CTraceContext
Source§fn clone(&self) -> W3CTraceContext
fn clone(&self) -> W3CTraceContext
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 W3CTraceContext
impl Debug for W3CTraceContext
Source§impl Display for W3CTraceContext
impl Display for W3CTraceContext
Source§impl PartialEq for W3CTraceContext
impl PartialEq for W3CTraceContext
impl Eq for W3CTraceContext
impl StructuralPartialEq for W3CTraceContext
Auto Trait Implementations§
impl Freeze for W3CTraceContext
impl RefUnwindSafe for W3CTraceContext
impl Send for W3CTraceContext
impl Sync for W3CTraceContext
impl Unpin for W3CTraceContext
impl UnsafeUnpin for W3CTraceContext
impl UnwindSafe for W3CTraceContext
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