Skip to content

Update opentelemetry_exporter headers at runtime. #962

@francois-caddet

Description

@francois-caddet

Descritption

I try to export my elixir app's traces to the official opentelemetry collector.

To configure headers to inject in the opentelemetry exporter http/grpc messages, what I understoud is that we must set it in a [{String.t(), String.t()}] list.

My issue is that the collector I use is protected by an OAuth2 bearer authentication method:

  • The app authenticate on an IAM and get a short live jwt token.
  • The collector is configured with the OIDC extension and so check the token authenticity on the standart oidc endpoint for that.
  • Every application set the token given by the IAM in the header authorization: Bearer {TOKEN} when they emit an otlp event.
  • This token expire in a short amount of time an so the apps need to renew it periodicaly.

All the process to authenticate on the IAM and to renew the token on time is not an issue. However, since I get the new token,
I don't know how I could update the token passed in the headers of the exporter.

Proposed options

This issue may be fixed with one or more of these updates:

  • Add a method to update the exporter options at runtime or at least the headers. It may be in two steps (e.g.: :opentelemetry_exporter.set_opt(:otlp_headers, [{"authorization", "Bearer {MY_NEW_BEARER}") then :opentelemetry_exporter.refresh_config())
  • Accepting a function as config value for the :otlp_headers which will be called for each message send.
  • A maybe more flexible option could be to give a way to add http/grpc middlewares/interceptors at startup or in the config. I thing it can easyly be implemented for grpc with grpcbox but for the http export, I have no idea.

Other options explored

Setting the application env otlp_headers before the token expire an letting the exporter crash and restart.
Tryed it without success for now. NB: I'm a junior in elixir development.
Anyway, I feel it is not the nicer way to handle my usecase.

Any other options accepted ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions