[−][src]Trait opentelemetry::api::BaggageExt
Methods for sorting and retrieving baggage data in a context.
Required methods
fn current_with_baggage<T: IntoIterator<Item = KeyValue>>(baggage: T) -> Self
Returns a clone of the current context with the included name / value pairs.
Examples
use opentelemetry::api::{BaggageExt, Context, KeyValue, Value}; let cx = Context::current_with_baggage(vec![KeyValue::new("my-name", "my-value")]); assert_eq!( cx.baggage().get("my-name"), Some(&Value::String("my-value".to_string())), )
fn with_baggage<T: IntoIterator<Item = KeyValue>>(&self, baggage: T) -> Self
Returns a clone of the given context with the included name / value pairs.
Examples
use opentelemetry::api::{BaggageExt, Context, KeyValue, Value}; let some_context = Context::current(); let cx = some_context.with_baggage(vec![KeyValue::new("my-name", "my-value")]); assert_eq!( cx.baggage().get("my-name"), Some(&Value::String("my-value".to_string())), )
fn with_cleared_baggage(&self) -> Self
Returns a clone of the given context with the included name / value pairs.
Examples
use opentelemetry::api::{BaggageExt, Context, KeyValue, Value}; let cx = Context::current().with_cleared_baggage(); assert_eq!(cx.baggage().len(), 0);
fn baggage(&self) -> &Baggage
Returns a reference to this context's baggage, or the default empty baggage if none has been set.