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

Dynamic headers to OTLP Exporter

Open sakthiraam opened this issue 1 year ago • 16 comments

Is your feature request related to a problem? Please describe. Today only static headers are allowed in OTLP exporter. I would like to have an option to pass dynamic headers to OTLP exporter.

Describe the solution you'd like Ability to set the header in OTLP exporter dynamically from attributes processor for example. receivers: otlp: protocols: grpc: include_metadata: true

attributes/get_tenant: actions: - key: "my-dynamic-value" from_attributes: app_tenant action: upsert otlp: endpoint: "http://some-endpoint:4317" headers: my-dynamic-header: <my-dynamic-value>

Describe alternatives you've considered If header_setter extension in OTEL contrib repo can support from_attributes then we will consider that as an alternatives.

Additional context

Today in our pipeline we have a OTLP receiver , resource attributes, attributes processor, OTLP exporter and auth extension to support us our multi-tenancy setup. The headers that auth extension requires from our client can be accessed as our pipeline is pretty simple.

As we are getting more applications getting onboarded to OTEL based implementation we want to implement tail sampling and introduce Kafka for temporary storage to allow scaling.

With the new setup we will have multiple pipelines 1 - OTEL Agent --> OTEL Receiver --> Kafka Exporter. 2 - Kafka Receiver --> Load Balancer --> Resource attributes & attributes processor --> Tail sampling processor --> Routing Processor --> OTLP Exporter

With this new pipeline (2) we can't access the headers (from_context) sent by the OTEL Agent hence we are not able to use the header_setter extension for our multi-tenancy use-case.

Upon checking we can use Routing processor which has the ability to get value from attributes (from_attributes) and based on match it can forward to specific exporter. But again, the headers we need to set is static and when new applications are onboarded we need to keep updating the pipeline configuration.

sakthiraam avatar May 31 '23 11:05 sakthiraam

This sounds like a reasonable request to me. I can work on this once it is triaged.

shivanshuraj1333 avatar Jun 20 '23 09:06 shivanshuraj1333

Hi, Any plan to implement this request? I believe this is a must have feature in multi-tenant environment. Could you please consider this feature?

logamanig avatar Aug 04 '23 12:08 logamanig

This should really help any enterprise landscape with a variety of application systems where multi tenancy is integral requirement. Hope this feature gets picked up soon.

roshanmohammed avatar Sep 08 '23 12:09 roshanmohammed

Hi, a much needed feature while working with multi tenants. Appreciate if this could be considered for implementation.

ykapilesh avatar Sep 08 '23 12:09 ykapilesh

have you take à look at https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/headerssetterextension ?

jtama avatar Sep 13 '23 12:09 jtama

Hi @jtama , Thanks for your reply. We are already using the headersetterextension today but this extension is missing the from_attributes option to get the information for the tenant to dynamically populate it. Its only has option to get it from header or hard-code the tenant information. Hence I thought of checking if this option can be added to the core otel exporter option.

image

sakthiraam avatar Sep 21 '23 01:09 sakthiraam

Indeed, I completely missed the second pipeline... I know what you ask exists in the loki exporter, and is far more simpler to use than the extension...

jtama avatar Sep 21 '23 05:09 jtama

Hi @jtama , For logs exporting to Loki backend we are using the options you explained in the Loki exporter but our current use case is for traces which we need to export in OTLP format to a Tempo which is multi-tenant enabled. Hence looking for native support in OTEL exporter.

sakthiraam avatar Sep 26 '23 14:09 sakthiraam

Any progress on this? headerssetterextension doesn't seem a good approach. Ideally we should be able to dynamically set the tenantID from attribute...

andrecastro avatar Oct 31 '23 18:10 andrecastro

/label help-wanted

sakthiraam avatar Dec 20 '23 04:12 sakthiraam

is this request still active ? We have a similar requirement to populate dynamic headers to tempo .

dfi470 avatar Feb 27 '24 12:02 dfi470

We have also a similar requirement for metrics (and in the future also for traces). Therefore we would like to set the header X-Scope-OrgID dynamically. I have found an alternative solution with a custom processor implementation: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27901. Maybe this would be a solution to be integrated into in the OTEL contrib repo.

brunokoeferli avatar Feb 27 '24 13:02 brunokoeferli

same use case here. 👍 want to keep/convert an attribute/label read from kafka to X-Scope-OrgID

hicwic avatar Mar 11 '24 14:03 hicwic

same here please add it to an existing exporter or header_setter extension. 🙌🙌🤞

Garry1704 avatar Apr 22 '24 13:04 Garry1704

Yet another comment that we have this use case too.

gigi-at-zymergen avatar Apr 22 '24 18:04 gigi-at-zymergen

Thanks for letting us know this issue is important. I expect this feature will depend on this milestone: https://github.com/open-telemetry/opentelemetry-collector/milestone/67 and the functionality that currently lives in the client directory.

It is unlikely that approvers/maintainers take on this enhancement while we are pushing for 1.0, but we're open to hearing some solutions to this problem and someone else taking it up.

TylerHelmuth avatar Apr 22 '24 18:04 TylerHelmuth