Description
Is your feature request related to a problem? Please describe.
I'd like to leverage OTel context propagation to propagate my own custom Context scoped-values, similar to io.opentelemetry.api.baggage.Baggage
. However, I do not want to use Baggage because the custom values are their own separate logical set of data with their own specific constraints whose propagation I'd like to independently enable or disable (e.g. -Dotel.propagators=tracecontext,baggage,custom
or -Dotel.propagators=tracecontext,custom
).
I'd also like to read my custom values from an application's Context.current()
, which were extracted from a custom header by a custom propagator via an OTel Java agent extension.
However, this doesn't seem to work because the Java agent context is separate from the application context, except for Span and Baggage, which have a ContextKeyBridge
.
Describe the solution you'd like
Therefore, I'd like to be able to register a custom ContextKeyBridge
in AgentContextWrapper.CONTEXT_KEY_BRIDGES
, perhaps similar to how custom propagators are registered, so that my custom Context scoped-values can be shared between agent and application.
Describe alternatives you've considered
- Just use Baggage; however, Baggage allows for any data to be set and propagated. I only want a small set of data with very specific constraints (e.g. a UUID and an Instant).
- It's theoretically possible to (ab)use Baggage to pass data between the Java agent and application contexts; however, it would be messy, leaky, and have unwanted side effects.
Additional context
No response