Struct opentelemetry::trace::TraceState
source · [−]pub struct TraceState(_);
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
pub fn from_key_value<T, K, V>(trace_state: T) -> Result<Self, TraceStateError> where
T: IntoIterator<Item = (K, V)>,
K: ToString,
V: ToString,
pub fn from_key_value<T, K, V>(trace_state: T) -> Result<Self, TraceStateError> where
T: IntoIterator<Item = (K, V)>,
K: ToString,
V: ToString,
Creates a new TraceState
from the given key-value collection.
Examples
use opentelemetry::trace::{TraceState, TraceStateError};
let kvs = vec![("foo", "bar"), ("apple", "banana")];
let trace_state: Result<TraceState, TraceStateError> = TraceState::from_key_value(kvs);
assert!(trace_state.is_ok());
assert_eq!(trace_state.unwrap().header(), String::from("foo=bar,apple=banana"))
Retrieves a value for a given key from the TraceState
if it exists.
pub fn insert<K, V>(
&self,
key: K,
value: V
) -> Result<TraceState, TraceStateError> where
K: Into<String>,
V: Into<String>,
pub fn insert<K, V>(
&self,
key: K,
value: V
) -> Result<TraceState, TraceStateError> where
K: Into<String>,
V: Into<String>,
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.
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.
Creates a new TraceState
header string, delimiting each key and value with a =
and each
entry with a ,
.
Creates a new TraceState
header string, with the given key/value delimiter and entry delimiter.
Trait Implementations
Returns the “default value” for a type. Read more
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for TraceState
impl Send for TraceState
impl Sync for TraceState
impl Unpin for TraceState
impl UnwindSafe for TraceState
Blanket Implementations
Mutably borrows from an owned value. Read more