Skip to content

fix(telemetry): send dedicated-mode traces to the client's explicit server_url - #650

Merged
rbarbadillo merged 2 commits into
mainfrom
rbarbadillo/obs-2925-telemetry-server-url
Oct 30, 2026
Merged

rbarbadillo merged 2 commits into
mainfrom
rbarbadillo/obs-2925-telemetry-server-url

Conversation

@rbarbadillo

@rbarbadillo rbarbadillo commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Problem

Dedicated-mode telemetry always exported to https://api.mistral.ai/telemetry/v1/traces, whatever the client's server_url was. For other deployments, Mistral(server_url="https://<host>", api_key=<key>) sent API calls to that host but spans to api.mistral.ai, which got a 401 (one exporter log line), so all SDK traces were lost.

Change

The exporter endpoint now resolves as:

  1. MISTRAL_OTLP_TRACES_ENDPOINT, if set and non-blank (unchanged override)
  2. the client's explicit server_url + /telemetry/v1/traces
  3. https://api.mistral.ai/telemetry/v1/traces

The named eu/us servers keep exporting to api.mistral.ai on purpose. The regional hosts don't serve the telemetry route (unauthenticated probes: /v1/models returns 401 on all three hosts, /telemetry/v1/traces returns 401 on api.mistral.ai but 404 on api.eu/api.us). Following them would break telemetry for regional users.

MISTRAL_TELEMETRY_ENDPOINT is kept (now built from SERVERS[SERVER_GLOBAL] + MISTRAL_TELEMETRY_PATH) for backward compatibility. Only hand-owned files changed: src/mistralai/extra/ and the hand-written telemetry section of README.md.

Behaviour changes

  • A client whose server_url points at a proxy or gateway now exports traces there instead of api.mistral.ai. Set MISTRAL_OTLP_TRACES_ENDPOINT to keep the old destination.
  • An explicit server_url="https://api.eu.mistral.ai" (rather than server="eu") gets a 404 for telemetry. Use server="eu" or the env override.

Tests

New TestTelemetryEndpoint cases use a real client and TracerProvider with a mock transport and exporter, for both explicit configure_telemetry and MISTRAL_SDK_TELEMETRY=dedicated auto-config. They cover:

  • default, global, eu and us servers (traces go to api.mistral.ai)
  • custom URL, trailing slash, path prefix, localhost:port, and server="eu" with an explicit URL (traces go to server_url)
  • blank env overrides and env override precedence

Local results: observability suite 208 passed + 40 subtests; unittest discovery of test_telemetry.py OK; ruff check, mypy and pyright clean.

Verify end-to-end against a deployment with a custom server_url.

Follow-ups

Regional hosts don't serve /telemetry/v1/traces yet. Once they do, the SDK can follow the named regions too.

@rbarbadillo
rbarbadillo merged commit 8fdbff0 into main Oct 30, 2026
11 checks passed
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.

2 participants