feat(server-utils): Implement orchestrion-based instrumentation for vercel-ai v6#21658
Conversation
9145703 to
abad3a9
Compare
3417464 to
d05d40e
Compare
size-limit report 📦
|
d05d40e to
98fac43
Compare
JPeer264
left a comment
There was a problem hiding this comment.
Haven't found any major issues. Tests are failing though and clanker has some objections
| return isRecord(model) ? asString(model[field]) : undefined; | ||
| } | ||
|
|
||
| function asString(value: unknown): string | undefined { |
There was a problem hiding this comment.
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
05fd48d to
89bf321
Compare
89bf321 to
c3f5431
Compare
| // 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)( |
There was a problem hiding this comment.
q: Why are we skipping this test on v7?
There was a problem hiding this comment.
added a better comment here!
| * 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}). |
There was a problem hiding this comment.
nit: I'd drop this, it doesn't really add much for understanding, it explains bindTracingChannelToSpan which should already be explained elsewhere.
There was a problem hiding this comment.
this has all been refactored a bit and is hopefully easier/cleaner to understand now.
f3e62c4 to
1731a89
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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.
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

When using orchestrion, this replaces the regular
vercelAiIntegrationwith 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.