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
sourceimpl TraceState
impl TraceState
sourcepub fn from_key_value<T, K, V>(trace_state: T) -> Result<TraceState, TraceError>where
T: IntoIterator<Item = (K, V)>,
K: ToString,
V: ToString,
pub fn from_key_value<T, K, V>(trace_state: T) -> Result<TraceState, TraceError>where
T: IntoIterator<Item = (K, V)>,
K: ToString,
V: ToString,
Creates a new TraceState
from the given key-value collection.
Examples
use opentelemetry_api::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) -> Result<TraceState, TraceError>where
K: Into<String>,
V: Into<String>,
pub fn insert<K, V>(&self, key: K, value: V) -> Result<TraceState, TraceError>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.
sourcepub fn delete<K>(&self, key: K) -> Result<TraceState, TraceError>where
K: Into<String>,
pub fn delete<K>(&self, key: K) -> Result<TraceState, TraceError>where
K: Into<String>,
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
sourceimpl Clone for TraceState
impl Clone for TraceState
sourcefn clone(&self) -> TraceState
fn clone(&self) -> TraceState
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for TraceState
impl Debug for TraceState
sourceimpl Default for TraceState
impl Default for TraceState
sourcefn default() -> TraceState
fn default() -> TraceState
Returns the “default value” for a type. Read more
sourceimpl FromStr for TraceState
impl FromStr for TraceState
type Err = TraceError
type Err = TraceError
The associated error which can be returned from parsing.
sourcefn from_str(s: &str) -> Result<TraceState, <TraceState as FromStr>::Err>
fn from_str(s: &str) -> Result<TraceState, <TraceState as FromStr>::Err>
Parses a string s
to return a value of this type. Read more
sourceimpl Hash for TraceState
impl Hash for TraceState
sourceimpl PartialEq<TraceState> for TraceState
impl PartialEq<TraceState> for TraceState
sourcefn eq(&self, other: &TraceState) -> bool
fn eq(&self, other: &TraceState) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
impl Eq for TraceState
impl StructuralEq for TraceState
impl StructuralPartialEq for TraceState
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.