1313//! Baggage can be sent between systems using a baggage propagator in
1414//! accordance with the [W3C Baggage] specification.
1515//!
16+ //! Note: Baggage is not automatically added to any telemetry. Users have to
17+ //! explicitly add baggage entries to telemetry items.
18+ //!
19+ //!
1620//! [W3C Baggage]: https://w3c.github.io/baggage
1721use crate :: { Context , Key , KeyValue , StringValue } ;
1822use std:: collections:: hash_map:: Entry ;
@@ -75,10 +79,10 @@ impl Baggage {
7579 /// ```
7680 /// use opentelemetry::{baggage::Baggage, StringValue};
7781 ///
78- /// let mut cc = Baggage::new();
79- /// let _ = cc .insert("my-name", "my-value");
82+ /// let mut baggage = Baggage::new();
83+ /// let _ = baggage .insert("my-name", "my-value");
8084 ///
81- /// assert_eq!(cc .get("my-name"), Some(&StringValue::from("my-value")))
85+ /// assert_eq!(baggage .get("my-name"), Some(&StringValue::from("my-value")))
8286 /// ```
8387 pub fn get < K : AsRef < str > > ( & self , key : K ) -> Option < & StringValue > {
8488 self . inner . get ( key. as_ref ( ) ) . map ( |( value, _metadata) | value)
@@ -90,11 +94,11 @@ impl Baggage {
9094 /// ```
9195 /// use opentelemetry::{baggage::{Baggage, BaggageMetadata}, StringValue};
9296 ///
93- /// let mut cc = Baggage::new();
94- /// let _ = cc .insert("my-name", "my-value");
97+ /// let mut baggage = Baggage::new();
98+ /// let _ = baggage .insert("my-name", "my-value");
9599 ///
96100 /// // By default, the metadata is empty
97- /// assert_eq!(cc .get_with_metadata("my-name"), Some(&(StringValue::from("my-value"), BaggageMetadata::from(""))))
101+ /// assert_eq!(baggage .get_with_metadata("my-name"), Some(&(StringValue::from("my-value"), BaggageMetadata::from(""))))
98102 /// ```
99103 pub fn get_with_metadata < K : AsRef < str > > (
100104 & self ,
@@ -113,10 +117,10 @@ impl Baggage {
113117 /// ```
114118 /// use opentelemetry::{baggage::Baggage, StringValue};
115119 ///
116- /// let mut cc = Baggage::new();
117- /// let _ = cc .insert("my-name", "my-value");
120+ /// let mut baggage = Baggage::new();
121+ /// let _ = baggage .insert("my-name", "my-value");
118122 ///
119- /// assert_eq!(cc .get("my-name"), Some(&StringValue::from("my-value")))
123+ /// assert_eq!(baggage .get("my-name"), Some(&StringValue::from("my-value")))
120124 /// ```
121125 pub fn insert < K , V > ( & mut self , key : K , value : V ) -> Option < StringValue >
122126 where
@@ -127,7 +131,7 @@ impl Baggage {
127131 . map ( |pair| pair. 0 )
128132 }
129133
130- /// Inserts a name/value pair into the baggage.
134+ /// Inserts a name/value(+metadata) pair into the baggage.
131135 ///
132136 /// Same with `insert`, if the name was not present, [`None`] will be returned.
133137 /// If the name is present, the old value and metadata will be returned.
@@ -139,10 +143,10 @@ impl Baggage {
139143 /// ```
140144 /// use opentelemetry::{baggage::{Baggage, BaggageMetadata}, StringValue};
141145 ///
142- /// let mut cc = Baggage::new();
143- /// let _ = cc .insert_with_metadata("my-name", "my-value", "test");
146+ /// let mut baggage = Baggage::new();
147+ /// let _ = baggage .insert_with_metadata("my-name", "my-value", "test");
144148 ///
145- /// assert_eq!(cc .get_with_metadata("my-name"), Some(&(StringValue::from("my-value"), BaggageMetadata::from("test"))))
149+ /// assert_eq!(baggage .get_with_metadata("my-name"), Some(&(StringValue::from("my-value"), BaggageMetadata::from("test"))))
146150 /// ```
147151 pub fn insert_with_metadata < K , V , S > (
148152 & mut self ,
0 commit comments