-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access headers in processor #2401
Comments
returns the HTTP headers for any gRPC receiver. However the processor cannot be used after the batch processor. The same approach uses https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/master/processor/routingprocessor However, I also need to access the headers from Jaeger HTTP thrift (14268) receiver. |
@bogdandrutu @tigrannajaryan could we add HTTP headers to the context in the HTTP based receivers? |
I think if this goes forward there should be a way to access headers (metadata) decoupled from the receiver (e.g. a method to access it instead of the need to call grpc |
@pavolloffay we were just discussing this, and I don't know what is the right approach. The problem with adding it to the Context is that if batch span processor is the first processor that will drop the context, so most likely we have to carry this with the data itself and not the Context. |
Correct, I understand this as a limitation of the current design which is fine for us since the processor that access the headers will run immediately after the receiver. Shall we start thinking on merging contexts in the batch processor or changing the API to bind context to each original tracedata? |
Related to #2495 which has similar requirements. |
@jpkrohling is this related to the auth extensions pass-through? Can you take this? |
This was requested earlier, and some aspects of this might be doable with the auth work. Once the passthrough PR is done, it should be easy to use the same technique to implement this, by storing the headers in the Resource* structs. |
Are there any thoughts on this? Or ideas how an implementation should look like? |
We have the |
@jpkrohling I do believe that this does not provide enough information about why this is needed. If somebody random comes and say I need "foo" are you going to implement it? I am not suggesting that this is not important and we should not do it, but would be good to understand why this is needed. |
No, this one has been requested a few times in the past already though. The typical reasoning is using the incoming HTTP headers down the pipeline to make tenancy decisions, either at the processor level (routing processor, for instance), or exporter level (passthrough of API keys). |
@jpkrohling awesome, but because of unnecessary clone cost in some cases I would recommend to do this opt-in. Have a Boolean in the HttpClientSettings to enable this |
Sounds reasonable to me. |
@jpkrohling @bogdandrutu maybe I am missing something but the first step here is to receive the headers from the receiver and then pass to the processors, how is HTTPClientSettings involved? |
I believe he meant the server settings, used by most receivers |
Updated the PR now cloning headers optionally. |
how can we receive the headers and send same to exporter for multi tennat? |
Take a look at the header setter extension for one of the possible solutions: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/headerssetter |
I tried to use but then collector stops. also please let me know what from_context means |
It's a new extension, I believe it might be available starting from 0.59.0. |
is there any available method to access headers from receiver and use it in exporter as tennat? |
What's your concrete use case? Without knowing that, I can only provide general information. HTTP headers are part of the client metadata. You can access them via the attributes or resources processor, adding that information to the data points. Exporters would then be responsible for accessing this data. The header setter helps in this last part by allowing the headers to be used as values for headers on outgoing HTTP calls. |
i am using zipkin as receiver and taking headers from application, also metatdata: true and now i want to use this headers in exporter to diffrentiate tennat on the basis of headers.
|
Your best bet is indeed the header setter. That's exactly the use-case it's solving. |
What is from context here in headerssetter |
Is your feature request related to a problem? Please describe.
I would like to access HTTP headers in the processor pipeline and add attribute to span/resource - e.g. tenant ID.
Describe the solution you'd like
Read the headers from the context object in a processor. The headers which should be injected into the context could be specified in the receiver config.
Describe alternatives you've considered
A custom implementation of Zipkin/OTLP receiver that does that.
Additional context
Related issue #2101
The text was updated successfully, but these errors were encountered: