Repository navigation
fix(fireworks): trace TypeScript Fireworks clients through the shared OpenAI route - #509
Merged
Merged
Conversation
… OpenAI route FireworksInstrumentation wrapped nonexistent OpenAI.prototype resources and exported no spans on any supported SDK while reporting isPatched() true. - @traceai/openai attributes the exact api.fireworks.ai host to fireworks. - FireworksInstrumentation is now a deprecated delegate to OpenAIInstrumentation: one DeprecationWarning per process, same public entry points, OpenAI SDK 4.x-7.x. - Only the instrumentor that applied a patch removes it, so disabling a second instrumentor sharing the SDK no longer silently stops tracing. - Network-isolated contracts on packed tarballs for SDK 4.0.0, 5.23.2, 6.0.0 and 7.47.0, plus a migration README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ared route Co-Authored-By: Claude Opus 5.5 <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
@traceai/fireworks(TypeScript) exported no spans on any supported OpenAI SDK. It wrappedOpenAI.prototype.chat.completionsand similar paths, which don't exist (the SDK creates resources per client instance), butisPatched()still returnedtrue. This PR sends Fireworks through the shared OpenAI-compatible route, matching the Python change in #367.@traceai/openai: the exact hostapi.fireworks.ainow maps togen_ai.provider.name=fireworks. This matchespython/frameworks/openai/traceai_openai/_providers.py. Look-alike hosts, a barefireworks.aiand custom proxies keep the existingopenaifallback.@traceai/fireworks:FireworksInstrumentationis now a deprecated subclass ofOpenAIInstrumentation. It keeps the same public entry points (FireworksInstrumentation,isPatched,VERSION, constructor options,setTracerProvider,manuallyInstrument,enable/disable). Constructing it emits oneDeprecationWarning(TRACEAI_FIREWORKS_DEPRECATED) per process. A delegate works here, unlike Python, because the shared package already supports the Fireworks package's SDK floor (4.0.0) and goes up to 7.x. The 750-line copy of the instrumentation goes away, and the package now depends only on@traceai/openai.@traceai/openai): only the instance that applied a patch may remove it. Before this fix, if two instrumentors shared the SDK (for exampleFireworksInstrumentationplusOpenAIInstrumentationduring migration, or twoOpenAIInstrumentations), disabling the one that didn't patch unwrapped the SDK. Tracing then stopped silently, because the CommonJS require hook still asks every instance tounpatch. The fix is a per-instanceWeakSetplus a guard inunpatch(3 lines).Behavior changes for existing
@traceai/fireworksusersOpenAI Chat Completions/OpenAI Completions/OpenAI Embeddings. The instrumentation scope is the shared instrumentor's (@traceai/fi-instrumentation-openai).instrumentationNameis no longer@traceai/fireworks. Before this PR the package produced no spans at all.openaipeer range goes from>=4.0.0(optional) to^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0, the same as@traceai/openai. This is not a breaking change: no version in the old range was ever actually traced.traceConfig.Known limits (documented, not changed):
@traceai/openaicopy. An app that pins an older@traceai/openainext to the new@traceai/fireworksgets a nested copy without the guard. The migration step "remove@traceai/fireworks" avoids this.Reproduction (fails before the fix)
979c2716:provider.test.tsfailed forapi.fireworks.ai.isPatched()stayedtrueafterdisable(), no deprecation warning.patchOwnership.test.tsfailed: after the non-owner was disabled,isPatched()wasfalseand no span was exported.both=truefailed on 4.0.0 and 7.47.0 with real require hooks, loggingNo original to unwrap to.Validation (outbound network denied, loopback only)
@traceai/openaifull Jest suite: 185 passed, 2 skipped (both skipped before this PR too), 15 snapshots.@traceai/fireworksJest suite: 16/16 on the locked SDK and on OpenAI 4.0.0 and 7.47.0 (OPENAI_TEST_MODULE). Shared provider, wire and ownership tests: 68/68 on 4.0.0, 74/74 on 7.47.0.@traceai/openai+@traceai/fireworks) installed in a clean consumer, exporting real OTLP/JSON to a loopback receiver, on OpenAI 4.0.0, 5.23.2, 6.0.0 and 7.47.0. Each version ran four modes: automatic CommonJS hooks, explicitmanuallyInstrument, each with and withoutOpenAIInstrumentationalso enabled. 11–12 passed per run, 0 failures. Covered:fireworksspan for chat, completions, embeddings, chat and completion streams, and HTTP errors;api.openai.comclient in the same process staysopenai;--strictfor ESM and CJS.register()and loopback OTLP (5.23.2, 7.47.0), and typechecks. It is skipped on 4.0.0 because that SDK's node-fetch shim ignores the recipe's synthetic globalfetch.pnpm install --frozen-lockfile --ignore-scripts,release_plan.py --check,bootstrap_audit.py --checkand 69 release unit tests passed. The lockfile change is confined to thetraceai_fireworksimporter and was hand-edited, not re-resolved.New CI:
.github/workflows/fireworks-typescript-tests.ymlruns the tarball contracts, README, ESM and Jest steps on 4.0.0, 5.23.2, 6.0.0 and 7.47.0 in a loopback-only network namespace.openai-sdk-contracts.ymlnow also runspatchOwnership.test.tsacross its matrix.Release
Both packages already have release-please config and manifest entries, and this PR has no version or changelog edits. The npm release runs in dependency order, so
@traceai/openaipublishes before@traceai/fireworks.workspace:^becomes the released@traceai/openaiversion range. The fix reaches users only once both packages are on npm. A customer docs page is held until then; no docs PR has been opened.Related PRs
provider.ts/providerHostsWire.test.ts/provider.test.tscontain fix(openai): attribute dedicated Baseten TypeScript endpoints #336's resolver plus later hosts, and dev'sapiPromise.tsis identical to fix(openai): preserve lazy TypeScript API promises #410's. Neither branch was changed or closed here.🤖 Generated with Claude Code