Skip to content

fix(telemetry): only follow the client's explicit serverURL for dedicated-mode traces - #289

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

rbarbadillo merged 2 commits into
mainfrom
raquelbarbadillo/telemetry-explicit-server-url

Conversation

@rbarbadillo

@rbarbadillo rbarbadillo commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Problem

Dedicated-mode telemetry already exported to the client's server URL, but it differed from the Python SDK in two ways:

  1. It followed the named eu/us servers. It used the resolved _baseURL (and the hook's baseURL), so server: "eu" exported to https://api.eu.mistral.ai/telemetry/v1/traces. The regional hosts don't serve the telemetry route (404), so those traces were lost.
  2. It dropped path prefixes. new URL("/telemetry/v1/traces", base) turned https://gateway.example.com/mistral into https://gateway.example.com/telemetry/v1/traces.

Change

The exporter endpoint now resolves as:

  1. MISTRAL_OTLP_TRACES_ENDPOINT, if set and non-blank (unchanged override)
  2. the client's explicit serverURL + /telemetry/v1/traces, keeping any path prefix and stripping trailing slashes
  3. https://api.mistral.ai/telemetry/v1/traces

MISTRAL_TELEMETRY_BASE_URL is now derived from ServerList[ServerGlobal]; the exported constants are unchanged. Only hand-owned files changed: src/extra/observability/, its tests, and the hand-written telemetry section of README.md.

Behaviour changes

  • A client using server: "eu" or server: "us" now exports traces to api.mistral.ai instead of the regional host.
  • A serverURL with a path prefix now keeps that prefix in the telemetry endpoint.
  • An explicit serverURL: "https://api.eu.mistral.ai" (rather than server: "eu") still gets a 404 for telemetry. Use server: "eu" or the env override.

Tests

New tests/extra/observability/telemetry-endpoint.test.ts uses a real Mistral client with a mock fetcher and a mocked OTLP exporter, for both explicit configureTelemetry and MISTRAL_SDK_TELEMETRY=dedicated auto-config. It covers:

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

Against the previous implementation, 6 of the 26 new cases fail (eu, us, path prefix × both modes).

…ated-mode traces

Named eu/us servers keep exporting to api.mistral.ai since the regional
hosts don't serve /telemetry/v1/traces, and path prefixes on serverURL
are now preserved.
@rbarbadillo rbarbadillo self-assigned this Oct 30, 2026
…ependencies

The dedicated telemetry endpoint tests load @opentelemetry/sdk-trace-base and
@opentelemetry/resources for real. They are optional peer dependencies, which
npm install doesn't pull in, so the tests failed in CI. Users still don't need
to install them.
@rbarbadillo
rbarbadillo merged commit 50b2bc1 into main Oct 30, 2026
4 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