Skip to content

feat(server-utils): Migrate OpenAI integration to orchestrion - #21877

Merged
nicohrubec merged 3 commits into
developfrom
nh/openai-orchestrion
Jul 3, 2026
Merged

feat(server-utils): Migrate OpenAI integration to orchestrion#21877
nicohrubec merged 3 commits into
developfrom
nh/openai-orchestrion

Conversation

@nicohrubec

@nicohrubecnicohrubec commented Jul 1, 2026

Copy link
Copy Markdown
Member

Adds an orchestrion based OpenAI integration to server-utils, covering all the APIs and both streaming and non-streaming mode. Leaves the core integration intact and only exports the necessary utils that are needed for the orchestrion integration.

Closes#20912

Comment threadpackages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
@nicohrubec
nicohrubecforce-pushed the nh/openai-orchestrion branch from b53ebd6 to 8149b88CompareJuly 1, 2026 09:29
@github-actions

github-actionsBot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.59 kB--
@sentry/browser - with treeshaking flags26.03 kB--
@sentry/browser (incl. Tracing)46.24 kB--
@sentry/browser (incl. Tracing + Span Streaming)48 kB--
@sentry/browser (incl. Tracing, Profiling)51.01 kB--
@sentry/browser (incl. Tracing, Replay)85.49 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags75.1 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)90.19 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.84 kB--
@sentry/browser (incl. Feedback)44.76 kB--
@sentry/browser (incl. sendFeedback)32.38 kB--
@sentry/browser (incl. FeedbackAsync)37.51 kB--
@sentry/browser (incl. Metrics)28.67 kB--
@sentry/browser (incl. Logs)28.91 kB--
@sentry/browser (incl. Metrics & Logs)29.59 kB--
@sentry/react29.38 kB--
@sentry/react (incl. Tracing)48.51 kB--
@sentry/vue33.03 kB--
@sentry/vue (incl. Tracing)48.11 kB--
@sentry/svelte27.61 kB--
CDN Bundle30 kB--
CDN Bundle (incl. Tracing)48.22 kB--
CDN Bundle (incl. Logs, Metrics)31.57 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.53 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.77 kB--
CDN Bundle (incl. Tracing, Replay)85.68 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.97 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.5 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.77 kB--
CDN Bundle - uncompressed89.35 kB--
CDN Bundle (incl. Tracing) - uncompressed145.92 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.05 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed149.89 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.59 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed264.93 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed268.89 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed278.63 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed282.58 kB--
@sentry/nextjs (client)50.95 kB--
@sentry/sveltekit (client)46.65 kB--
@sentry/core/server78.31 kB+0.05%+34 B 🔺
@sentry/core/browser64.66 kB+0.08%+46 B 🔺
@sentry/node-core63.17 kB--
@sentry/node123.15 kB-0.01%-2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.7 kB--
@sentry/node - without tracing74.22 kB--
@sentry/aws-serverless85.01 kB--
@sentry/cloudflare (withSentry) - minified181.52 kB--
@sentry/cloudflare (withSentry)449.12 kB--

View base workflow run

@nicohrubec
nicohrubecforce-pushed the nh/openai-orchestrion branch 2 times, most recently from e03ecce to 856774bCompareJuly 1, 2026 10:15
Comment threadpackages/node/src/sdk/experimentalUseDiagnosticsChannelInjection.ts Outdated
@nicohrubec
nicohrubecforce-pushed the nh/openai-orchestrion branch 5 times, most recently from 127e3b2 to c9ec0e1CompareJuly 1, 2026 11:14
@nicohrubecnicohrubec changed the title feat(node): Port OpenAI chat completions to orchestrionfeat(node): Add orchestrion-based OpenAI integrationJul 1, 2026
@nicohrubecnicohrubec changed the title feat(node): Add orchestrion-based OpenAI integrationfeat(server-utils): Migrate OpenAI integration to orchestrionJul 1, 2026
@nicohrubecnicohrubec changed the title feat(server-utils): Migrate OpenAI integration to orchestrionfeat(server-utils): Migrate OpenAI integration to orchestrion (non-streaming)Jul 1, 2026
@nicohrubecnicohrubec changed the title feat(server-utils): Migrate OpenAI integration to orchestrion (non-streaming)feat(server-utils): Migrate OpenAI integration to orchestrionJul 1, 2026

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9ca6a54. Configure here.

@nicohrubec
nicohrubec marked this pull request as ready for review July 1, 2026 16:42
@nicohrubec
nicohrubec requested a review from a team as a code ownerJuly 1, 2026 16:42
@nicohrubec
nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a teamJuly 1, 2026 16:42
Comment threadpackages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/node';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: I think these tests can be removed after #21911 has been rebased?

@nicohrubec
nicohrubecforce-pushed the nh/openai-orchestrion branch from 30a9558 to db3e09bCompareJuly 2, 2026 14:47
Adds the orchestrion diagnostics-channel OpenAI integration (chat, responses,
embeddings, conversations) and registers it in the channelIntegrations map.
Skips span creation when a higher-level provider (e.g. langchain) already
instruments the SDK to avoid double spans.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubecforce-pushed the nh/openai-orchestrion branch from db3e09b to 62e81c0CompareJuly 2, 2026 16:15
Comment threadpackages/server-utils/src/integrations/tracing-channel/openai.ts Outdated
nicohrubecand others added 2 commits July 3, 2026 08:33
# Conflicts:
#	packages/server-utils/src/orchestrion/index.ts
… integration
Let errors bubble to the global handlers instead of capturing them as unhandled
at the instrumentation level, matching the DB/cache channel subscribers.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubec merged commit 27f34ed into developJul 3, 2026
297 checks passed
@nicohrubec
nicohrubec deleted the nh/openai-orchestrion branch July 3, 2026 07:44
lux-in-tenebris-lucet pushed a commit to lux-in-tenebris-lucet/sentry-javascript that referenced this pull request Aug 8, 2026
… instrumentation level
The exported instrumentOpenAiClient, instrumentAnthropicAiClient and
instrumentGoogleGenAIClient wrappers captured provider errors with
mechanism.handled = false and then rethrew, so the SDK classified the
error as an unhandled crash before the application's retry or fallback
logic ran. A call that succeeded on retry still produced an unhandled
event, and each retry produced another one.
Applies the convention established for the channel-based OpenAI
integration in getsentry#21877 to the manual client instrumentation, which is the
only available path on the edge and serverless runtimes. Error span
status and the original error identity are unchanged.
The anthropic suite asserted this divergence directly, expecting the
model-error event only while orchestrion was disabled. Both paths agree
now, so that branch and its expectation are gone.
Captures are kept where a provider reports an error as data on an
otherwise successful call, since the caller never sees those as a thrown
error. The AI integration suites no longer mask these events with
.ignore('event'), so they fail if the capture returns.
Dropping the capture also left the .catch() in createWithResponseWrapper
rethrowing into a promise nothing observes, which is not a handler at
all: awaiting the two promises in sequence orphans the second whenever
the first rejects. They are awaited together now.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lux-in-tenebris-lucet pushed a commit to lux-in-tenebris-lucet/sentry-javascript that referenced this pull request Aug 13, 2026
… instrumentation level
The exported instrumentOpenAiClient, instrumentAnthropicAiClient and
instrumentGoogleGenAIClient wrappers captured provider errors with
mechanism.handled = false and then rethrew, so the SDK classified the
error as an unhandled crash before the application's retry or fallback
logic ran. A call that succeeded on retry still produced an unhandled
event, and each retry produced another one.
Applies the convention established for the channel-based OpenAI
integration in getsentry#21877 to the manual client instrumentation, which is the
only available path on the edge and serverless runtimes. Error span
status and the original error identity are unchanged.
The anthropic suite asserted this divergence directly, expecting the
model-error event only while orchestrion was disabled. Both paths agree
now, so that branch and its expectation are gone.
Captures are kept where a provider reports an error as data on an
otherwise successful call, since the caller never sees those as a thrown
error. The AI integration suites no longer mask these events with
.ignore('event'), so they fail if the capture returns.
Dropping the capture also left the .catch() in createWithResponseWrapper
rethrowing into a promise nothing observes, which is not a handler at
all: awaiting the two promises in sequence orphans the second whenever
the first rejects. They are awaited together now.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for freeto 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.

Rewrite SentryOpenAiInstrumentation to orchestrion

4 participants

@nicohrubec@isaacs@logaretm@JPeer264