fix(server-utils): Record Vercel AI experimental_telemetry.metadata on gen_ai spans - #24721
Conversation
size-limit report 📦
|
JPeer264
left a comment
There was a problem hiding this comment.
Implementation LGTM. However I'm not sure if we should send vercel.ai specific attributes. I added @andreiborza and @RulaKhaled who know more about status quo on these fields and if we should (re-)add them
RulaKhaled
left a comment
There was a problem hiding this comment.
Also lgtm. I’d bring this up in the agent tracing channel before merging, vercel.ai.telemetry.metadata.* attributes aren’t in @sentry/conventions, they probably can’t be convention constants but maybe we could register a prefix
| const baseAttributes: Record<string, string | number | boolean> = { | ||
| const baseAttributes: SpanAttributes = { | ||
| [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, | ||
| ...telemetryMetadataAttributes(event.telemetryMetadata), |
There was a problem hiding this comment.
I wonder if this should be gated on recordInputs or dataCollection.genAI
e652f6b to
aea4552
Compare
Good call! Pinged them for input. |
|
👋 @mydea — Please review this PR when you get a chance! |
|
👋 @andreiborza — Please review this PR when you get a chance! |
RulaKhaled
left a comment
There was a problem hiding this comment.
Could you add the prefix to our conventions please?
… on gen_ai spans v10 got `vercel.ai.telemetry.metadata.<key>` attributes from the AI SDK's own OTel spans. In v11, `ai` 4 to 6 go through the orchestrion subscriber, which never read `metadata`, so v11 dropped it. The orchestrion subscriber now passes the metadata to the channel subscriber, which sets it as span attributes when each span starts. The `invoke_agent`, `generate_content` and `embeddings` spans get the attributes, and `execute_tool` spans don't. This matches the AI SDK, which leaves metadata off its `ai.toolCall` spans. fixes JS-3800 fixes #24720 Re: #24706 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PR open: getsentry/sentry-conventions#662 |
e5e058e to
94d0f9e
Compare
v10 got
vercel.ai.telemetry.metadata.<key>attributes from the AI SDK's own OTel spans. In v11,ai4 to 6 go through the orchestrion subscriber, which never readmetadata, so v11 dropped it.The orchestrion subscriber now passes the metadata to the channel subscriber, which sets it as span attributes when each span starts. The
invoke_agent,generate_contentandembeddingsspans get the attributes, andexecute_toolspans don't. This matches the AI SDK, which leaves metadata off itsai.toolCallspans.fixes JS-3800
fixes #24720
Re: #24706