Repository navigation
fix(telemetry): send dedicated-mode traces to the client's explicit server_url - #650
Merged
Merged
Conversation
th-ch
approved these changes
Oct 30, 2026
… deployment wording
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.
Problem
Dedicated-mode telemetry always exported to
https://api.mistral.ai/telemetry/v1/traces, whatever the client'sserver_urlwas. 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:
MISTRAL_OTLP_TRACES_ENDPOINT, if set and non-blank (unchanged override)server_url+/telemetry/v1/traceshttps://api.mistral.ai/telemetry/v1/tracesThe named
eu/usservers keep exporting to api.mistral.ai on purpose. The regional hosts don't serve the telemetry route (unauthenticated probes:/v1/modelsreturns 401 on all three hosts,/telemetry/v1/tracesreturns 401 on api.mistral.ai but 404 on api.eu/api.us). Following them would break telemetry for regional users.MISTRAL_TELEMETRY_ENDPOINTis kept (now built fromSERVERS[SERVER_GLOBAL]+MISTRAL_TELEMETRY_PATH) for backward compatibility. Only hand-owned files changed:src/mistralai/extra/and the hand-written telemetry section ofREADME.md.Behaviour changes
server_urlpoints at a proxy or gateway now exports traces there instead of api.mistral.ai. SetMISTRAL_OTLP_TRACES_ENDPOINTto keep the old destination.server_url="https://api.eu.mistral.ai"(rather thanserver="eu") gets a 404 for telemetry. Useserver="eu"or the env override.Tests
New
TestTelemetryEndpointcases use a real client and TracerProvider with a mock transport and exporter, for both explicitconfigure_telemetryandMISTRAL_SDK_TELEMETRY=dedicatedauto-config. They cover:server="eu"with an explicit URL (traces go toserver_url)Local results: observability suite 208 passed + 40 subtests; unittest discovery of
test_telemetry.pyOK;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/tracesyet. Once they do, the SDK can follow the named regions too.