Skip to content

@opentelemetry/exporter-trace-otlp-grpc ignores headers #5520

@ruslan-mikhailov

Description

@ruslan-mikhailov

Hello!

According to the documentation, it is possible to provide custom headers when configuring the OTLP trace exporter:

new OTLPTraceExporter({
    // optional - default url is http://localhost:4318/v1/traces
    url: '<your-otlp-endpoint>/v1/traces',
    // optional - collection of custom headers to be sent with each request, empty by default
    headers: {},
  })

However, the headers option is ignored in the @opentelemetry/exporter-trace-otlp-grpc package, as seen in the implementation here: https://github.com/open-telemetry/opentelemetry-js/blob/v1.x/experimental/packages/otlp-grpc-exporter-base/src/configuration/convert-legacy-otlp-grpc-options.ts#L36

This behavior can be confusing for library users, as demonstrated in these discussions:
https://community.grafana.com/t/sending-one-simple-trace-to-tempo-via-http/82901/3
https://community.grafana.com/t/how-to-send-traces-from-node-js-otel-sdk-to-tempo/81283
Possible workarounds:

  1. Use metadata property
  2. Setting OTEL_EXPORTER_OTLP_HEADERS env variable

Are there any specific reasons why the gRPC exporter ignores the headers option? If so, I suggest explicitly documenting this behavior in the module's documentation to avoid confusion.

  • This only affects the JavaScript OpenTelemetry library
  • This may affect other libraries, but I would like to get opinions here first

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions