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

Composite extractors and injectors

Open slinkydeveloper opened this issue 4 years ago • 4 comments

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.

slinkydeveloper avatar Jul 02 '21 08:07 slinkydeveloper

I can contribute to this tweaking the MultiTextMapPropagator

slinkydeveloper avatar Jul 02 '21 08:07 slinkydeveloper

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!

jkwatson avatar Jul 02 '21 16:07 jkwatson

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:

slinkydeveloper avatar Jul 05 '21 07:07 slinkydeveloper

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

ghost avatar Jul 09 '21 12:07 ghost