Description
Feature Request
Opentelemetry Rust provides APIs for Baggage. However, there is no integration with the tracing
framework, probably because of its lack of support for distributed tracing.
Baggage has two main uses:
- For propagation across systems. This is currently possible with the Opentelemetry rust libraries. One may use the BaggagePropagator from
opentelemetry_sdk
to addBaggage
to anExtractor
. - However, Baggage, as defined in the docs, "is contextual information that’s passed between spans". I have tried several options and I just can't find any mechanism to set
Baggage
for the trace, so that any span within it can add to it or propagate context usingBaggagePropagator
.
The limitation probably comes from the immutability aspect of Context. It's easy to create a new Context using something like:
let ctx_with_baggage = Context::map_current(|cx| cx.with_baggage([KeyValue::new("uid", "value".to_string())]));
But then there is no way to attach it anywhere, resulting in the span getting lost and never accessible for any span created within the same trace.
Motivation
Being able to share values for things like customer ids, session id, etc. across a trace and, ultimately, propagate it.
Proposal
There is an API provided by tracing-opentelemetry
which allows replacing the current trace's context with a new one, so that Baggage can be added to it.
Alternatives
Opentelemetry Rust supports this, but not within the tracing
framework.