Repository navigation
Conversation
Recognize bounded dedicated and regional model hostnames without treating arbitrary Baseten subdomains as model endpoints. Pin host boundaries and real SDK-to-OTLP contracts on the declared OpenAI floor and registry latest. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Preserve SDK cleanup and cancellation propagation while ending each span once. Cover native floor/latest transports, close failures, error privacy, and repeated cleanup in Baseten CI contracts. Co-Authored-By: Claude Code <noreply@anthropic.com>
Keep all lifecycle assertions on Python 3.10 while matching cancellation messages only where Task propagates them. Only error-masking variants skip on the Poetry-locked core that predates that optional feature. Co-Authored-By: Claude Code <noreply@anthropic.com>
Route the SDK alias through instrumented close so early cleanup, close errors and cancellation finish the span once. Cover direct aclose and contextlib.aclosing on dedicated and regional Baseten streams. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
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
Fix the remaining Baseten attribution gap in the maintained Python OpenAI instrumentor. Model APIs at
inference.baseten.coalready map tobaseten; dedicated and regionalmodel-*.api.baseten.coendpoints still map toopenaion dev.register()→ loopback OTLP contracts for hosted/dedicated/regional endpoints, sync/async calls, Chat Completions/Responses/embeddings, completed streams, HTTP errors, content masking, credentials, model metadata, token usage, normalized/lookalike URLs, and mutable client endpoints. Each operation exports exactly one span.1.69.0) and registrylatest, printing the resolved version and preserving the existing Model APIs recipe contracts.This is the Python companion to the separate TypeScript repair in #336, not a replacement or duplicate of it. No unfinished Python Baseten PR or branch was found. Current dev was merged normally before final validation.
Failing-first evidence
Against dev
045f5f0f2d024d61352a9ba5bdbbfe1ef60aa752, the initial regression matrix produced 70 failures and 52 passes on both OpenAI 1.69.0 and 3.42.1. All failures were dedicated/regional provider attribution. Hosted endpoints and negative controls already passed. The provider-mapping portion changes five production lines; the lifecycle follow-up below also repairs the shared request/stream wrappers. The final Baseten matrix includes 123 passing tests, including an additional mutable-client regression.Official endpoint references:
Synthetic resource tests prove instrumentor coverage, not that every Baseten deployment exposes every OpenAI resource.
Validation
Every local executable check ran with outbound networking denied except loopback. Dependencies were installed separately. Only synthetic credentials and model responses were used.
fi-instrumentation-otel==1.2.2: 474 passed, 18 skips on OpenAI 1.69.0 and 490 passed, 2 optional-package skips on registry-latest 3.42.1. The floor skips 16 new alias-specific cases because that SDK does not exposeAsyncStream.aclose(). Import paths confirmed the installed wheel/core were used. The skips are the separately installable Fireworks and vLLM migration integrations.register()and a loopback/tracer/v1/tracesreceiver: 6 passing runs, three endpoint shapes on each SDK version. The latest example uses the SDK's nativehttpx2transport; the floor useshttpx.git diff --checkpassed.Review round 1 lifecycle follow-up
Both findings were reproduced as pre-existing shared-instrumentor defects, not regressions in the hostname matcher. Explicit early close lost the span; async request/stream cancellation bypassed
Exceptionhandlers.devwas refreshed and already contained in the branch; no force-push or duplicate PR was needed.Review round 2 async close alias follow-up
The latest SDK's
AsyncStream.aclose()alias bypassed the proxy's instrumentedclose(), so direct calls andcontextlib.aclosing()closed HTTP responses without finishing early stream spans. This was another pre-existing lifecycle gap, not a provider-matcher regression.aclose()through the same instrumented close path, retaining SDK response cleanup, exception/cancellation propagation and once-only span finalization.devwas already contained in the branch.Review round 3 high-level stream helper follow-up
The SDK's high-level
chat.completions.stream()andresponses.stream()context managers close their HTTP response directly, bypassing raw stream close. Empty and partially consumed helpers therefore lost their spans despite the earlier raw-stream fixes. The review reproducer showed 8 failures / 4 exhausted-stream controls passing on each SDK version. A task-safe, per-response close observer now finalizes these spans without replacing the SDK's helpers or adding a second span; raw stream close and cancellation keep their previous error behavior. It also preserves user exceptions andFI_HIDE_ERROR_DETAILSmasking on high-level context exits.devbase normally. Release plan and whitespace checks pass. GitHub CI for this head is still running; no force-push, merge, or release was performed.Review round 2 synchronous request interruption follow-up
KeyboardInterruptinside the synchronous native HTTP request previously propagated before ending its active span. The sync wrapper now finalizes it as ERROR, records the exception through the existing privacy-aware span wrapper, and re-raises the original interruption.origin/devmerge: 526 passed / 18 skipped on the floor and 542 passed / 2 skipped on latest. All executable tests used an outbound-denying sandbox and synthetic credentials. Release-plan check and frozen TypeScript lockfile installation passed.Documentation and release boundaries
The docs-site page is held locally until a release contains the corrected provider mapping; the current published
traceAI-openaiis 0.1.12. No docs PR, registry publication, tag, merge, or issue closure is part of this change. The existing standalone Baseten recipe remains explicitly Model APIs-only; dedicated endpoints use the OpenAI client directly.Live Baseten calls, Future AGI Cloud execution, full docs-site rendering, and product screenshots were not performed. Baseten's separate Performance Client and non-OpenAI protocols are outside this route. The regression checks preserve the existing model attribute semantics rather than changing those shared conventions in this attribution fix.
🤖 Generated with Claude Code