Trait opentelemetry::baggage::BaggageExt [−][src]
pub trait BaggageExt { fn with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
&self,
baggage: T
) -> Self; fn current_with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
baggage: T
) -> Self; fn with_cleared_baggage(&self) -> Self; fn baggage(&self) -> &Baggage; }
Expand description
Methods for sorting and retrieving baggage data in a context.
Required methods
fn with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
&self,
baggage: T
) -> Self
[src]
fn with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
&self,
baggage: T
) -> Self
[src]Returns a clone of the given context with the included name-value pairs.
Examples
use opentelemetry::{baggage::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::from("my-value")), )
fn current_with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
baggage: T
) -> Self
[src]
fn current_with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
baggage: T
) -> Self
[src]Returns a clone of the current context with the included name-value pairs.
Examples
use opentelemetry::{baggage::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::from("my-value")), )
fn with_cleared_baggage(&self) -> Self
[src]
fn with_cleared_baggage(&self) -> Self
[src]Returns a clone of the given context with the included name-value pairs.
Examples
use opentelemetry::{baggage::BaggageExt, Context, KeyValue, Value}; let cx = Context::current().with_cleared_baggage(); assert_eq!(cx.baggage().len(), 0);
Implementors
fn with_baggage<T: IntoIterator<Item = I>, I: Into<KeyValueMetadata>>(
&self,
baggage: T
) -> Self
[src]