[−][src]Struct opentelemetry::baggage::Baggage
A set of name-value pairs describing user-defined properties.
Baggage Names
- ASCII strings according to the token format, defined in RFC2616, Section 2.2
Baggage Values
- URL encoded UTF-8 strings.
Baggage Value Metadata
Additional metadata can be added to values in the form of a property set,
represented as semi-colon ;
delimited list of names and/or name-value pairs,
e.g. ;k1=v1;k2;k3=v3
.
Limits
- Maximum number of name-value pairs:
180
. - Maximum number of bytes per a single name-value pair:
4096
. - Maximum total length of all name-value pairs:
8192
.
Implementations
impl Baggage
[src]
pub fn new() -> Self
[src]
Creates an empty Baggage
.
pub fn get<T: Into<Key>>(&self, key: T) -> Option<&Value>
[src]
Returns a reference to the value associated with a given name
Examples
use opentelemetry::{baggage::Baggage, Value}; let mut cc = Baggage::new(); let _ = cc.insert("my-name", "my-value"); assert_eq!(cc.get("my-name"), Some(&Value::from("my-value")))
pub fn get_with_metadata<T: Into<Key>>(
&self,
key: T
) -> Option<&(Value, BaggageMetadata)>
[src]
&self,
key: T
) -> Option<&(Value, BaggageMetadata)>
Returns a reference to the value and metadata associated with a given name
Examples
use opentelemetry::{baggage::{Baggage, BaggageMetadata}, Value}; let mut cc = Baggage::new(); let _ = cc.insert("my-name", "my-value"); // By default, the metadata is empty assert_eq!(cc.get_with_metadata("my-name"), Some(&(Value::from("my-value"), BaggageMetadata::from(""))))
pub fn insert<K, V>(&mut self, key: K, value: V) -> Option<Value> where
K: Into<Key>,
V: Into<Value>,
[src]
K: Into<Key>,
V: Into<Value>,
Inserts a name-value pair into the baggage.
If the name was not present, None
is returned. If the name was present,
the value is updated, and the old value is returned.
Examples
use opentelemetry::{baggage::Baggage, Value}; let mut cc = Baggage::new(); let _ = cc.insert("my-name", "my-value"); assert_eq!(cc.get("my-name"), Some(&Value::from("my-value")))
pub fn insert_with_metadata<K, V, S>(
&mut self,
key: K,
value: V,
metadata: S
) -> Option<(Value, BaggageMetadata)> where
K: Into<Key>,
V: Into<Value>,
S: Into<BaggageMetadata>,
[src]
&mut self,
key: K,
value: V,
metadata: S
) -> Option<(Value, BaggageMetadata)> where
K: Into<Key>,
V: Into<Value>,
S: Into<BaggageMetadata>,
Inserts a name-value pair into the baggage.
Same with insert
, if the name was not present, None
will be returned.
If the name is present, the old value and metadata will be returned.
Examples
use opentelemetry::{baggage::{Baggage, BaggageMetadata}, Value}; let mut cc = Baggage::new(); let _ = cc.insert_with_metadata("my-name", "my-value", "test"); assert_eq!(cc.get_with_metadata("my-name"), Some(&(Value::from("my-value"), BaggageMetadata::from("test"))))
pub fn remove<K: Into<Key>>(
&mut self,
key: K
) -> Option<(Value, BaggageMetadata)>
[src]
&mut self,
key: K
) -> Option<(Value, BaggageMetadata)>
Removes a name from the baggage, returning the value corresponding to the name if the pair was previously in the map.
pub fn len(&self) -> usize
[src]
Returns the number of attributes for this baggage
pub fn is_empty(&self) -> bool
[src]
Returns true
if the baggage contains no items.
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
Gets an iterator over the baggage items, sorted by name.
Trait Implementations
impl Debug for Baggage
[src]
impl Default for Baggage
[src]
impl FromIterator<(Key, (Value, BaggageMetadata))> for Baggage
[src]
fn from_iter<I: IntoIterator<Item = (Key, (Value, BaggageMetadata))>>(
iter: I
) -> Self
[src]
iter: I
) -> Self
impl FromIterator<KeyValue> for Baggage
[src]
fn from_iter<I: IntoIterator<Item = KeyValue>>(iter: I) -> Self
[src]
impl FromIterator<KeyValueMetadata> for Baggage
[src]
fn from_iter<I: IntoIterator<Item = KeyValueMetadata>>(iter: I) -> Self
[src]
impl<'a> IntoIterator for &'a Baggage
[src]
Auto Trait Implementations
impl RefUnwindSafe for Baggage
impl Send for Baggage
impl Sync for Baggage
impl Unpin for Baggage
impl UnwindSafe for Baggage
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,