Skip to content

feat(server-utils): Implement orchestrion-based instrumentation for vercel-ai v6#21658

Merged
mydea merged 14 commits into
developfrom
fn/try-orchestrion
Jul 3, 2026
Merged

feat(server-utils): Implement orchestrion-based instrumentation for vercel-ai v6#21658
mydea merged 14 commits into
developfrom
fn/try-orchestrion

Conversation

@mydea

@mydea mydea commented Jun 19, 2026

Copy link
Copy Markdown
Member

When using orchestrion, this replaces the regular vercelAiIntegration with the channel-variant. This today supports vercel ai v6 and v7 (v5/v4 support TBD).

Test coverage exists and everything passes. This does not add any event processors etc. anymore, everything works inside of the integrations.

OTEL Spans emitted directly by vercel-ai v6 or below are ignored to avoid double instrumentation.

@mydea mydea self-assigned this Jun 19, 2026
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
Comment thread dev-packages/node-integration-tests/suites/tracing/vercelai/v6_v7/test.ts Outdated
@mydea mydea force-pushed the fn/vercel-ai-v7 branch 9 times, most recently from 9145703 to abad3a9 Compare June 25, 2026 11:33
Base automatically changed from fn/vercel-ai-v7 to develop June 25, 2026 13:20
@mydea mydea force-pushed the fn/try-orchestrion branch from 3417464 to d05d40e Compare June 26, 2026 11:13
Comment thread packages/opentelemetry/src/asyncContextStrategy.ts Outdated
Comment thread packages/core/src/asyncContext/index.ts Outdated
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.03 kB - -
@sentry/browser (incl. Tracing) 46.24 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.01 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.01 kB - -
@sentry/browser (incl. Tracing, Replay) 85.49 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.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/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.51 kB - -
@sentry/vue 33.03 kB - -
@sentry/vue (incl. Tracing) 48.11 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 kB - -
CDN Bundle (incl. Tracing) 48.24 kB - -
CDN Bundle (incl. Logs, Metrics) 31.57 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.54 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.77 kB - -
CDN Bundle (incl. Tracing, Replay) 85.7 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.49 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.78 kB - -
CDN Bundle - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.96 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.93 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.59 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.97 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.62 kB - -
@sentry/nextjs (client) 50.95 kB - -
@sentry/sveltekit (client) 46.65 kB - -
@sentry/core/server 78.38 kB - -
@sentry/core/browser 64.73 kB - -
@sentry/node-core 63.2 kB - -
@sentry/node 123.2 kB +0.02% +22 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.72 kB -0.01% -1 B 🔽
@sentry/node - without tracing 74.24 kB +0.01% +1 B 🔺
@sentry/aws-serverless 85.02 kB - -
@sentry/cloudflare (withSentry) - minified 181.56 kB - -
@sentry/cloudflare (withSentry) 449.18 kB - -

View base workflow run

@mydea mydea force-pushed the fn/try-orchestrion branch from d05d40e to 98fac43 Compare June 29, 2026 09:42
@mydea mydea changed the title WIP: Implement orchestrion-based instrumentation for vercel-ai v6 feat(server-utils): Implement orchestrion-based instrumentation for vercel-ai v6 Jun 29, 2026
@mydea mydea marked this pull request as ready for review June 29, 2026 09:42
@mydea mydea requested a review from a team as a code owner June 29, 2026 09:42
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team June 29, 2026 09:42
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated

@JPeer264 JPeer264 left a comment

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.

Haven't found any major issues. Tests are failing though and clanker has some objections

Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
return isRecord(model) ? asString(model[field]) : undefined;
}

function asString(value: unknown): string | undefined {

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.

super-l: Maybe it makes sense to outsource these functions in a helper? vercel-ai-dc-subscriber.ts is also using some of the helpers

@mydea mydea force-pushed the fn/try-orchestrion branch from 05fd48d to 89bf321 Compare June 29, 2026 12:57
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
// A single model instance shared by two concurrent `streamText` calls carries only one
// captured-parent slot, so both model calls must still land under their own `invoke_agent` — not
// collapse onto whichever operation resolved the shared model last.
test.skipIf(version === '7' && nodeVersion === 18)(

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.

q: Why are we skipping this test on v7?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added a better comment here!

Comment on lines +30 to +34
* Like the v7 subscriber, each operation channel is wired up via
* {@link bindTracingChannelToSpan}, which binds the opened span into the runtime's
* async context for the duration of the traced call and ends it when the call
* settles. That binding is what lets the model call below find its enclosing
* `invoke_agent` span via the active context (see {@link resolveModelCallParent}).

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.

nit: I'd drop this, it doesn't really add much for understanding, it explains bindTracingChannelToSpan which should already be explained elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this has all been refactored a bit and is hopefully easier/cleaner to understand now.

@mydea mydea force-pushed the fn/try-orchestrion branch from c3f5431 to b26e0cf Compare July 2, 2026 07:24
Comment thread packages/server-utils/src/orchestrion/config.ts
@mydea mydea force-pushed the fn/try-orchestrion branch from b26e0cf to d82519d Compare July 2, 2026 08:26
Comment thread packages/server-utils/src/vercel-ai/vercel-ai-orchestrion-v6-subscriber.ts Outdated
@mydea mydea force-pushed the fn/try-orchestrion branch 2 times, most recently from f3e62c4 to 1731a89 Compare July 3, 2026 05:57

@cursor cursor Bot 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 2 potential issues.

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 1731a89. Configure here.

@mydea mydea force-pushed the fn/try-orchestrion branch from 1731a89 to 99cc8cd Compare July 3, 2026 11:43
@mydea mydea enabled auto-merge (squash) July 3, 2026 12:34
@mydea mydea merged commit 68fe9e8 into develop Jul 3, 2026
230 checks passed
@mydea mydea deleted the fn/try-orchestrion branch July 3, 2026 12:54
mydea added a commit that referenced this pull request Jul 6, 2026
This PR just splits up the orchestrion config for instrumentation into a
file per instrumentation, making it a bit cleaner and easier to follow.

This is on top of
#21658
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.

3 participants