Use public headers API#165
Draft
mendral-app[bot] wants to merge 1 commit into
Draft
Conversation
Replace direct access to private _session.headers attribute with a custom requests.Session subclass passed via the public 'session' constructor parameter. This prevents AttributeError crashes when the OTel exporter-otlp-proto-http package refactors its internals. - Add _DynamicHeadersSession that injects headers on every post() - Pass custom session to all three exporter constructors - Cap opentelemetry-exporter-otlp dependency at <2.0.0 - Add unit tests for dynamic header injection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_session.headersattribute with a customrequests.Sessionsubclass (_DynamicHeadersSession) that injects dynamic auth headers on everypost()call, passed via the publicsessionconstructor parameteropentelemetry-exporter-otlpdependency to<2.0.0to prevent future surprise breaking changesProblem
The
DynamicHeadersSpanExporter,DynamicHeadersMetricExporter, andDynamicHeadersLogExporterclasses accessself._session.headers.update(...)— a private attribute that was removed/renamed in neweropentelemetry-exporter-otlp-proto-httpversions, causingAttributeErrorcrashes and breaking all telemetry exports in production (SDK v0.2.55).Solution
Instead of accessing internal
_sessionafter construction, we now provide a custom session at construction time via the supportedsession=parameter. The_DynamicHeadersSessionsubclass overridespost()to callget_headers()before each request, ensuring fresh auth tokens are always injected without relying on any private OTel internals.Relates to: https://app.mendral.com/insights/01KTSHBMEP4GKW6S62CSMYS18Q
Note
Created by Mendral. Tag @mendral-app with feedback or questions.