Title: vercelAIIntegration: record AI SDK v7 runtimeContext (filtered by telemetry.includeRuntimeContext) as span attributes · Issue #24706 · getsentry/sentry-javascript · GitHub
Open Graph Title: vercelAIIntegration: record AI SDK v7 runtimeContext (filtered by telemetry.includeRuntimeContext) as span attributes · Issue #24706 · getsentry/sentry-javascript
X Title: vercelAIIntegration: record AI SDK v7 runtimeContext (filtered by telemetry.includeRuntimeContext) as span attributes · Issue #24706 · getsentry/sentry-javascript
Description: Problem Statement AI SDK v7 removed telemetry.metadata. Per-call metadata now goes in runtimeContext, and the app opts keys into telemetry with telemetry.includeRuntimeContext (telemetry docs, runtime context docs). @ai-sdk/otel records ...
Open Graph Description: Problem Statement AI SDK v7 removed telemetry.metadata. Per-call metadata now goes in runtimeContext, and the app opts keys into telemetry with telemetry.includeRuntimeContext (telemetry docs, runt...
X Description: Problem Statement AI SDK v7 removed telemetry.metadata. Per-call metadata now goes in runtimeContext, and the app opts keys into telemetry with telemetry.includeRuntimeContext (telemetry docs, runt...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/24706
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"vercelAIIntegration: record AI SDK v7 runtimeContext (filtered by telemetry.includeRuntimeContext) as span attributes","articleBody":"### Problem Statement\n\nAI SDK v7 removed `telemetry.metadata`. Per-call metadata now goes in `runtimeContext`, and the app opts keys into telemetry with `telemetry.includeRuntimeContext` ([telemetry docs](https://ai-sdk.dev/docs/ai-sdk-core/telemetry), [runtime context docs](https://ai-sdk.dev/v7/docs/ai-sdk-core/runtime-and-tool-context)). `@ai-sdk/otel` records the included keys as `ai.settings.runtimeContext.*`. On v6 the equivalent data arrived through `experimental_telemetry.metadata` as `vercel.ai.telemetry.metadata.*`.\n\nThe v7 channel subscriber in `@sentry/server-utils` (`vercel-ai-dc-subscriber`, added in #21613) never reads `runtimeContext`, so on v7 there is no way to attach request-level metadata (user, tenant, request id, ...) to gen_ai spans. The [integration docs](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/vercelai/) say not to combine `registerTelemetry` with `vercelAIIntegration`, so registering `@ai-sdk/otel` alongside it is not a workaround either.\n\n```ts\nawait streamText({\n model,\n messages,\n runtimeContext: { requestId: 'req_123', tenantId: 'acme', apiToken: 'secret' },\n telemetry: {\n isEnabled: true,\n functionId: 'support-chat',\n includeRuntimeContext: { requestId: true, tenantId: true },\n },\n});\n```\n\n- **Expected:** the `gen_ai.invoke_agent` span (and ideally its `gen_ai.generate_content` / `gen_ai.execute_tool` children) carries `requestId` and `tenantId`, and not `apiToken`.\n- **Actual:** none of the keys appear. The span has only `vercel.ai.operationId`, `vercel.ai.model.provider`, `vercel.ai.settings.maxRetries` and the `gen_ai.*` attributes.\n\nChecked against `@sentry/node` 10.71.0 and the `@sentry/server-utils` subscriber in 10.75.3 and 11.0.0, with `ai` 7.0.100 / 7.0.113 on Node.\n\n### Solution Brainstorm\n\n- In `buildInvokeAgentSpan`, set one attribute per `event.runtimeContext` key. `vercel.ai.settings.runtimeContext.\u003ckey>` would match `@ai-sdk/otel`'s `ai.settings.runtimeContext.*` under the existing `ai.*` to `vercel.ai.*` renaming.\n- Copy the same attributes onto child `generate_content` / `execute_tool` spans through the existing `callId` maps (like `operationIdByCallId`), since those channel events do not carry `runtimeContext`.\n- Optionally, record `event.toolContext` on `execute_tool` spans, which the AI SDK filters by `telemetry.includeToolsContext`.\n\n**Dependency on the AI SDK.** In `ai` \u003c= 7.0.113 the channel publishes `runtimeContext` / `toolsContext` **unfiltered**, ignoring `includeRuntimeContext` (vercel/ai#21442). Reading `event.runtimeContext` on those versions would send keys the app never opted in to telemetry. The fix is open in vercel/ai#21447, which filters channel events the same way as registered integrations. So this should only read the field on AI SDK versions that include that fix, or otherwise guard against unfiltered context.\n\n### Additional Context\n\n#24660 notes the same gap from the Cloudflare Think side (\"neither subscriber reads either field\").\n","author":{"url":"https://github.com/BrandonNoad","@type":"Person","name":"BrandonNoad"},"datePublished":"2026-09-24T16:19:58Z","url":"https://github.com/getsentry/sentry-javascript/issues/24706"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a2ac8db7-9e8d-7f67-e448-60e28d48e3cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2BA:2AA566:2519EF:33F65A:6B0438AA |
| html-safe-nonce | 34c4f73b2b258b3c8a8b0d2be5b10aab7a0b466a0485cb1c85b27ac701891253 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkJBOjJBQTU2NjoyNTE5RUY6MzNGNjVBOjZCMDQzOEFBIiwidmlzaXRvcl9pZCI6IjkyNjM0MTQ1MTU5NDYxMDg1OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3f3029cea715b211e6a56a0ecd51889310a43ea49fc092722b61fb99a59cfc6d |
| hovercard-subject-tag | issue:5571290550 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/24706/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b31fb028675ff63c13e0949a58fe06573ded3f3a56d9c8c27437170f1f643e9d/getsentry/sentry-javascript/issues/24706 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b31fb028675ff63c13e0949a58fe06573ded3f3a56d9c8c27437170f1f643e9d/getsentry/sentry-javascript/issues/24706 |
| og:image:alt | Problem Statement AI SDK v7 removed telemetry.metadata. Per-call metadata now goes in runtimeContext, and the app opts keys into telemetry with telemetry.includeRuntimeContext (telemetry docs, runt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | BrandonNoad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width