Skip to content

fix(sdk): support OpenTelemetry 1.39+ OTLPSpanExporter and prevent 401 race on logfile upload - #1477

Open
zainrizvi0611-cmd wants to merge 3 commits into
AgentOps-AI:mainfrom
zainrizvi0611-cmd:fix/otel-exporter-and-logfile-auth-race
Open

zainrizvi0611-cmd wants to merge 3 commits into
AgentOps-AI:mainfrom
zainrizvi0611-cmd:fix/otel-exporter-and-logfile-auth-race

Conversation

@zainrizvi0611-cmd

@zainrizvi0611-cmd zainrizvi0611-cmd commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

Fixes two runtime issues when using agentops with newer opentelemetry-exporter-otlp-proto-http (>= 1.39 / 1.45+) and short-lived scripts:

  1. OpenTelemetry OTLPSpanExporter attribute layout (agentops/sdk/exporters.py):
    • Newer releases of opentelemetry-exporter-otlp-proto-http store headers on self._client._headers and the requests.Session on self._client._transport._session instead of self._headers / self._session.
    • AuthenticatedOTLPExporter now falls back to self._client._headers and self._client._transport._session and propagates updated JWT headers cleanly.
  2. Prevent 401 race condition during upload_logfile on short-lived scripts (agentops/client/client.py, agentops/logging/instrument_logging.py):
    • When a short script exits immediately after agentops.init(), the atexit span shutdown could invoke InternalSpanProcessor.on_end -> upload_logfile() before the background authentication thread finished setting client.api.v4.auth_token, resulting in [agentops.InternalSpanProcessor] Error uploading logfile: Upload failed: 401.
    • Added Client.wait_for_auth() synchronization so the JWT token is awaited before span export and logfile upload.

This branch has not been deployed

No deployments
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.

1 participant