opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Ability to update baggage from SpanProcessor

Open srinusanduri opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. Opentelemetry Java instrumentation architecture provides the ability to plugin a custom SpanProcessor which provides the flexibility to perform our custom operations on every span start and end. However, there is a limitation, we can't add or update a baggage from SpanProcessor.

If the ability to add/update baggage from SpanProcessor is supported, it will be very helpful extension that allows us to add rich custom functionalities using a SpanProcessor. For example, one would like to dynamically compute a baggage value from span data (attributes, events, links) in a span processor and then add/update computed baggage value to current span context which can then be propagated to child spans.

I believe, we can achieve many customizations around span start and end if the baggage management functionality is supported from a Span Processor.

Describe the solution you'd like Ability to add/update baggage from Span Processor (both from onStart and onEnd operations).

Describe alternatives you've considered There is an open enhancement to support the baggage update functionality using global ContextCustomizer. But I believe Span Processor is the right place to achieve this. Moreover, SpanProcessor is applied to auto instrumented as well as manually instrumented spans whereas ContextCustomizers are applied only for auto instrumented spans.

srinusanduri avatar Nov 29 '22 05:11 srinusanduri

This would need to go through the specification before we would implement it unilaterally in Java. Please open an issue in the specification repository for this change.

jkwatson avatar Nov 29 '22 16:11 jkwatson