Repository navigation
fix(openai): attribute Vercel AI Gateway client spans - #460
Merged
Merged
Conversation
Keep shared client instrumentation and identify the documented gateway host without guessing its upstream provider. Exercise SDK floor/current contracts through OTLP/HTTP. Co-Authored-By: Claude Code <noreply@anthropic.com>
Keep gateway attribution contracts running with core 1.1.0 without claiming the stronger privacy behavior documented for core 1.2.2. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Merged
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.
Summary
Keep Vercel AI Gateway on the existing Python
traceAI-openaiintegration. Attribute the documentedai-gateway.vercel.shendpoint tovercel, not the SDK's defaultopenailabel. No package is created or deleted, andOpenAIInstrumentor().instrument(...)remains unchanged.Why this is the right route
Langfuse's gateway guide also reuses its OpenAI client integration. Vercel's native Trace Drains (reference last updated 2026-09-08) expose routing, fallback/provider attempts, tokens and cost, and list Braintrust as a native destination. Those drains omit prompts/completions and require a Pro/Enterprise team. They complement rather than replace client instrumentation.
The
vercellabel identifies the service known to the client, not the actual provider serving a fallback. This follows the OTel provider-name caveat: instrumentation identifies what it knows, which may differ from the actual model provider.No drain-to-Future-AGI recipe is advertised. A direct native drain still needs separate validation of FI authentication, project resources, GenAI mapping and deduplicated accounting.
register(project_name=...)configures application spans, not Vercel-generated traces; do not sum client and drain usage for the same requests.Reproduction and tests
On unchanged dev
d6a9966dd4d5d5fb344f7f5ab11b7483c2c2a6bc, the new regression suite has 26 failures and 8 passes with both OpenAI 1.69.0 and 3.42.0: the exact gateway host and every emitted gateway span reportopenairather thanvercel.With this fix, using published
fi-instrumentation-otel==1.2.2and Python 3.13:TraceConfigkeyword; the final suite uses the environment flag and tests attribution on the legacy core too. Stronger error/tool-definition privacy assertions remain mandatory with the guide's core 1.2.2, not falsely claimed for 1.1.0./tracer/v1/traces, FI auth headers versus gateway Bearer auth, andproject_name/project_typeresources. These are local collector contracts, not a claim of live FI ingestion validation.git diff --check, and a wheel build passed.All local execution tests ran under the existing macOS sandbox profile denying outbound networking except localhost; pytest also blocked non-local sockets. No vendor/model API, production ingestion API, or real credentials were used. The new CI matrix applies the same pytest socket restriction.
Review and release
Self-reviewed against the internal code-review playbook: minimal shared-map extension, exact matching, no new runtime dependency, public API/lifecycle preservation, no guessed fallback attribution, regression and failure-path coverage. No migrations, tenant/auth changes or OSS/EE boundary changes. No product
e2e/harness applies; SDK-to-OTLP tests cover this boundary. No ticket identifier was supplied for this audit item, so none is invented.Open PRs were checked before implementation. Other OpenAI provider fixes (including #424's explicit per-client override) and #369's TypeScript Vercel AI SDK/Eve changes do not implement this exact gateway attribution. No other branch was modified.
Release-please owns the version and changelog; neither is manually changed. The corrected customer guide is held locally until a package containing this mapping is published. Its install line must then be pinned to that release before a docs PR; no docs PR currently advertises the unreleased fix. No merge, tag or publication was performed.
🤖 Generated with Claude Code