Baggage#
OpenTelemetry Baggage is a context propagation mechanism that allows you to pass custom metadata or key-value pairs across service boundaries, providing additional context for distributed tracing and observability.
FastStream Baggage#
FastStream provides a convenient abstraction over baggage that allows you to:
- Initialize the baggage
- Propagate baggage through headers
- Modify the baggage
- Stop propagating baggage
Example#
To initialize the baggage and start distributing it, follow this example:
All interactions with baggage at the consumption level occurs through the CurrentBaggage object, which is automatically injected from the context:
Note
If you consume messages in batches, then the baggage from each message will be merged into the common baggage available through the get_all
method. However, you can still retrieve a list of all the baggage from the batch using the get_all_batch
method.