Skip to content

fix(v10/nextjs): Register Vercel AI span processors on Next.js - #23773

Merged
chargome merged 1 commit into
v10from
charlygomez/tet-2891-vercel-ai-nextjs-v10
Sep 1, 2026
Merged

fix(v10/nextjs): Register Vercel AI span processors on Next.js#23773
chargome merged 1 commit into
v10from
charlygomez/tet-2891-vercel-ai-nextjs-v10

Conversation

@chargome

@chargome chargome commented Aug 31, 2026

Copy link
Copy Markdown
Member
  • On Next.js, Vercel AI spans arrive unprocessed — raw ai.generateText / ai.toolCall, no gen_ai op
  • Next.js bundles ai, so it is never patched, and the Modules fallback misses workspace and transitive deps
  • Registered in init rather than on the default integration, which a user-supplied vercelAIIntegration() would replace
  • No e2e: reproducing needs ai hidden from Modules, and this gating is gone in v11
  • Telemetry still needs per-call experimental_telemetry: { isEnabled: true }; docs to follow

Ref: https://linear.app/getsentry/issue/TET-2891/vercel-ai-sdk-v6-instrumentation-is-broken-on-nextjs

@chargome chargome self-assigned this Aug 31, 2026
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3965bd0. Configure here.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.75 kB added added
@sentry/browser - with treeshaking flags 26.19 kB added added
@sentry/browser (incl. Tracing) 46.63 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 48.41 kB added added
@sentry/browser (incl. Tracing, Profiling) 51.38 kB added added
@sentry/browser (incl. Tracing, Replay) 85.88 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.51 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 90.61 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 103.25 kB added added
@sentry/browser (incl. Feedback) 44.92 kB added added
@sentry/browser (incl. sendFeedback) 32.54 kB added added
@sentry/browser (incl. FeedbackAsync) 37.68 kB added added
@sentry/browser (incl. Metrics) 28.83 kB added added
@sentry/browser (incl. Logs) 29.06 kB added added
@sentry/browser (incl. Metrics & Logs) 29.75 kB added added
@sentry/react 29.56 kB added added
@sentry/react (incl. Tracing) 48.89 kB added added
@sentry/vue 33.18 kB added added
@sentry/vue (incl. Tracing) 48.59 kB added added
@sentry/svelte 27.77 kB added added
CDN Bundle 30.14 kB added added
CDN Bundle (incl. Tracing) 48.59 kB added added
CDN Bundle (incl. Logs, Metrics) 31.72 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.89 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 71.01 kB added added
CDN Bundle (incl. Tracing, Replay) 86.11 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.42 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.91 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.19 kB added added
CDN Bundle - uncompressed 89.87 kB added added
CDN Bundle (incl. Tracing) - uncompressed 146.84 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.58 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.82 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.41 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.15 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 270.12 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.85 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.81 kB added added
@sentry/nextjs (client) 51.43 kB added added
@sentry/sveltekit (client) 47.04 kB added added
@sentry/core/server 80.57 kB added added
@sentry/core/browser 66.76 kB added added
@sentry/node-core 63.27 kB added added
@sentry/node 125.79 kB added added
@sentry/node (incl. diagnostics channel injection) 169.88 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B added added
@sentry/node/light 51.44 kB added added
@sentry/node - without tracing 74.95 kB added added
@sentry/aws-serverless 84.22 kB added added
@sentry/cloudflare (withSentry) - minified 202.59 kB added added
@sentry/cloudflare (withSentry) 498.65 kB added added

@chargome

Copy link
Copy Markdown
Member Author

bugbot run

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

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

Next.js bundles `ai`, so the module is never patched and the `Modules`
detection fallback misses workspace and transitive deps, leaving the AI
SDK's raw `ai.*` spans unprocessed.

Register the processors in `init` after the client exists, so an
explicitly constructed `vercelAIIntegration()` cannot override it, and
make `addVercelAiProcessors` idempotent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chargome
chargome force-pushed the charlygomez/tet-2891-vercel-ai-nextjs-v10 branch from 9a83b45 to e36dde0 Compare August 31, 2026 15:54
@chargome
chargome marked this pull request as ready for review September 1, 2026 06:02
@chargome
chargome requested a review from a team as a code owner September 1, 2026 06:02
@chargome
chargome requested review from RulaKhaled, andreiborza, nicohrubec and s1gr1d and removed request for a team September 1, 2026 06:02
@chargome
chargome merged commit 171c1fd into v10 Sep 1, 2026
313 checks passed
@chargome
chargome deleted the charlygomez/tet-2891-vercel-ai-nextjs-v10 branch September 1, 2026 09:28
chargome added a commit to getsentry/sentry-docs that referenced this pull request Sep 1, 2026
## DESCRIBE YOUR PR

On Next.js, `experimental_telemetry: { isEnabled: true }` is required on
every AI SDK call in **both** the Node and Edge runtimes — the page
scoped this to Edge and claimed the Node runtime patches call sites for
you.

The troubleshooting entry for raw span names presented `force: true` as
the whole fix, but alone it only registers the span processors and
yields zero AI spans; it now spells out both required steps. Verified on
`@sentry/nextjs@10.71.0`, Next.js 16.3.3, `ai@6`.

Also trimmed the Node/Edge split down to where the runtimes actually
differ. Not version-gated, since the fix that makes `force: true`
unnecessary (getsentry/sentry-javascript#23773) is unreleased. The page
is shared across ~25 platforms — every edit is inside a
`javascript.nextjs` `<PlatformSection>`.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants