opentelemetry-java
opentelemetry-java copied to clipboard
Composite extractors and injectors
Is your feature request related to a problem? Please describe. Implementation of composite propagator, with ability to choose which should be used as injectors and which should be used as extractors per spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md#create-a-composite-propagator
Describe the solution you'd like In my particular use case, I would love to support both w3c and b3 headers as "extractor", but I want to emit only w3c as trace headers.
I can contribute to this tweaking the MultiTextMapPropagator
I personally think this is a good addition, but I wonder if this is something that should be included in the official specification before we include it here. Would you be willing to create an issue in the specification repository to track this feature? Thanks!
Hi @jkwatson, my understanding of the paragraph here https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md#create-a-composite-propagator is exactly what I PR'd:
A list of Propagators or a list of Injectors and Extractors.
This project already ships the list of Propagators, my PR adds the ability to compose through a list of Injectors and Extractors. I don't understand what should be added to the spec in this case :smile:
This is subtle, as in Java both Extractor and Injector are modelled as methods of a single Propagator interface (which is of course allowed by the spec). I can however imagine that in order to be clear, the spec paragraph could be rephrased. For example:
Create a Composite Propagator
Required arguments:
A list of Propagators or separate lists of Injectors and Extractors.
Returns a new composite Propagator with the specified Propagators.
Note: if the language decides to implement Injector and Extractor as Propagator's methods, both lists will contain objects of the same type