-
Notifications
You must be signed in to change notification settings - Fork 134
Description
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_headerswhich 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 ;)