Skip to content

Use public headers API#165

Draft
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/use-public-headers-api
Draft

Use public headers API#165
mendral-app[bot] wants to merge 1 commit into
mainfrom
mendral/use-public-headers-api

Conversation

@mendral-app

@mendral-app mendral-app Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace direct access to private _session.headers attribute with a custom requests.Session subclass (_DynamicHeadersSession) that injects dynamic auth headers on every post() call, passed via the public session constructor parameter
  • Cap opentelemetry-exporter-otlp dependency to <2.0.0 to prevent future surprise breaking changes

Problem

The DynamicHeadersSpanExporter, DynamicHeadersMetricExporter, and DynamicHeadersLogExporter classes access self._session.headers.update(...) — a private attribute that was removed/renamed in newer opentelemetry-exporter-otlp-proto-http versions, causing AttributeError crashes and breaking all telemetry exports in production (SDK v0.2.55).

Solution

Instead of accessing internal _session after construction, we now provide a custom session at construction time via the supported session= parameter. The _DynamicHeadersSession subclass overrides post() to call get_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.

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
@mendral-app mendral-app Bot requested a review from a team June 10, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants