pub struct TraceState(/* private fields */);
trace
only.Expand description
TraceState carries system-specific configuration data, represented as a list of key-value pairs. TraceState allows multiple tracing systems to participate in the same trace.
Please review the W3C specification for details on this field.
Implementations§
Source§impl TraceState
impl TraceState
Sourcepub const NONE: TraceState = _
pub const NONE: TraceState = _
The default TraceState
, as a constant
Sourcepub fn from_key_value<T, K, V>(trace_state: T) -> TraceResult<Self>
pub fn from_key_value<T, K, V>(trace_state: T) -> TraceResult<Self>
Creates a new TraceState
from the given key-value collection.
§Examples
use opentelemetry::trace::TraceState;
let kvs = vec![("foo", "bar"), ("apple", "banana")];
let trace_state = TraceState::from_key_value(kvs);
assert!(trace_state.is_ok());
assert_eq!(trace_state.unwrap().header(), String::from("foo=bar,apple=banana"))
Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Retrieves a value for a given key from the TraceState
if it exists.
Sourcepub fn insert<K, V>(&self, key: K, value: V) -> TraceResult<TraceState>
pub fn insert<K, V>(&self, key: K, value: V) -> TraceResult<TraceState>
Inserts the given key-value pair into the TraceState
. If a value already exists for the
given key, this updates the value and updates the value’s position. If the key or value are
invalid per the W3 Spec an Err
is returned, else a new TraceState
with the
updated key/value is returned.
Sourcepub fn delete<K: Into<String>>(&self, key: K) -> TraceResult<TraceState>
pub fn delete<K: Into<String>>(&self, key: K) -> TraceResult<TraceState>
Removes the given key-value pair from the TraceState
. If the key is invalid per the
W3 Spec an Err
is returned. Else, a new TraceState
with the removed entry is returned.
If the key is not in TraceState
. The original TraceState
will be cloned and returned.
Sourcepub fn header(&self) -> String
pub fn header(&self) -> String
Creates a new TraceState
header string, delimiting each key and value with a =
and each
entry with a ,
.
Sourcepub fn header_delimited(
&self,
entry_delimiter: &str,
list_delimiter: &str,
) -> String
pub fn header_delimited( &self, entry_delimiter: &str, list_delimiter: &str, ) -> String
Creates a new TraceState
header string, with the given key/value delimiter and entry delimiter.
Trait Implementations§
Source§impl Clone for TraceState
impl Clone for TraceState
Source§fn clone(&self) -> TraceState
fn clone(&self) -> TraceState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TraceState
impl Debug for TraceState
Source§impl Default for TraceState
impl Default for TraceState
Source§fn default() -> TraceState
fn default() -> TraceState
Source§impl FromStr for TraceState
impl FromStr for TraceState
Source§impl Hash for TraceState
impl Hash for TraceState
Source§impl PartialEq for TraceState
impl PartialEq for TraceState
impl Eq for TraceState
impl StructuralPartialEq for TraceState
Auto Trait Implementations§
impl Freeze for TraceState
impl RefUnwindSafe for TraceState
impl Send for TraceState
impl Sync for TraceState
impl Unpin for TraceState
impl UnwindSafe for TraceState
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
trace
only.Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
trace
only.