vercelAIIntegration: record AI SDK v7 runtimeContext (filtered by telemetry.includeRuntimeContext) as span attributes
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Start at the v7 channel subscriber, especially buildInvokeAgentSpan and the existing callId maps in @sentry/server-utils. Check how runtimeContext is published and how the related vercel/ai filtering fix affects supported versions before tracing child generate_content and execute_tool spans. Done means opted-in requestId and tenantId reach the intended spans, apiToken does not, and coverage verifies the version behavior.
由索引模型根据 Issue 内容生成。
描述
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 the included keys as ai.settings.runtimeContext.*. On v6 the equivalent data arrived through experimental_telemetry.metadata as vercel.ai.telemetry.metadata.*.
The 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 say not to combine registerTelemetry with vercelAIIntegration, so registering @ai-sdk/otel alongside it is not a workaround either.
await streamText({
model,
messages,
runtimeContext: { requestId: 'req_123', tenantId: 'acme', apiToken: 'secret' },
telemetry: {
isEnabled: true,
functionId: 'support-chat',
includeRuntimeContext: { requestId: true, tenantId: true },
},
});
- Expected: the
gen_ai.invoke_agentspan (and ideally itsgen_ai.generate_content/gen_ai.execute_toolchildren) carriesrequestIdandtenantId, and notapiToken. - Actual: none of the keys appear. The span has only
vercel.ai.operationId,vercel.ai.model.provider,vercel.ai.settings.maxRetriesand thegen_ai.*attributes.
Checked 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.
Solution Brainstorm
- In
buildInvokeAgentSpan, set one attribute perevent.runtimeContextkey.vercel.ai.settings.runtimeContext.<key>would match@ai-sdk/otel'sai.settings.runtimeContext.*under the existingai.*tovercel.ai.*renaming. - Copy the same attributes onto child
generate_content/execute_toolspans through the existingcallIdmaps (likeoperationIdByCallId), since those channel events do not carryruntimeContext. - Optionally, record
event.toolContextonexecute_toolspans, which the AI SDK filters bytelemetry.includeToolsContext.
Dependency on the AI SDK. In ai <= 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.
Additional Context
#24660 notes the same gap from the Cloudflare Think side ("neither subscriber reads either field").
- 主要语言
- TypeScript
- 星标
- 8.7k
- 派生
- 1.9k
- 平均合并
- 1 天 16 小时
- 30 天内合并 PR
- 552
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/sentry-javascript 的其他 Issue
-
Browser Bug Next.js Traces
难度 2/5 1-3 小时 新手友好度 75/100
getsentry/sentry-javascript#24672 · 2 条评论 · 已指派 1 人 ·
-
javascript
难度 2/5 1-3 小时 新手友好度 75/100
getsentry/sentry-javascript#24200 · 2 条评论 ·
-
javascript Task
难度 2/5 1-3 小时 新手友好度 82/100
getsentry/sentry-javascript#24134 · 1 条评论 ·
-
Cloudflare Workers javascript Tests
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-javascript#24051 · 1 条评论 ·
-
Bug Bun javascript
难度 2/5 1-3 小时 新手友好度 92/100
getsentry/sentry-javascript#24045 · 1 条评论 ·
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
receptron/mulmoterminal#2264 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 78/100
components-web-app/docs#96 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 68/100
simonsobs/tileviewer#114 ·
-
难度 2/5 1-3 小时 新手友好度 75/100