Skip to content

fix(server-utils): Record Vercel AI experimental_telemetry.metadata on gen_ai spans - #24721

Merged
isaacs merged 2 commits into
developfrom
isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer
Oct 5, 2026
Merged

isaacs merged 2 commits into
developfrom
isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer

Conversation

@isaacs

@isaacs isaacs commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

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.

Values are cast to string, as discussed in the linked sentry-conventions PR. If this causes a problem we can revisit, but all extant examples found in the wild are strings already, so it is likely safe, and extremely cheap.

fixes JS-3800
fixes #24720
Re: #24706
Re: getsentry/sentry-conventions#662

@isaacs
isaacs requested review from a team as code owners September 24, 2026 22:11
@isaacs
isaacs requested review from JPeer264 and mydea and removed request for a team September 24, 2026 22:11
@linear-code

linear-code Bot commented Sep 24, 2026

Copy link
Copy Markdown

JS-3800

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.44 kB - -
@sentry/browser - with treeshaking flags 27.59 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.48 kB - -
@sentry/browser (incl. Tracing) 51.32 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.33 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.31 kB - -
@sentry/browser (incl. Tracing, Replay) 90.95 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.93 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.65 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.65 kB - -
@sentry/browser (incl. Feedback) 46.96 kB - -
@sentry/browser (incl. sendFeedback) 34.5 kB - -
@sentry/browser (incl. FeedbackAsync) 39.6 kB - -
@sentry/browser (incl. Metrics) 30.45 kB - -
@sentry/browser (incl. Logs) 30.74 kB - -
@sentry/browser (incl. Metrics & Logs) 31.39 kB - -
@sentry/react 31.28 kB - -
@sentry/react (incl. Tracing) 53.69 kB - -
@sentry/vue 37.41 kB - -
@sentry/vue (incl. Tracing) 54.23 kB - -
@sentry/svelte 29.47 kB - -
@sentry/remix (Remix 3 client bundle) 55.65 kB - -
CDN Bundle 31.13 kB - -
CDN Bundle (incl. Tracing) 51.87 kB - -
CDN Bundle (incl. Logs, Metrics) 33.37 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.81 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.1 kB - -
CDN Bundle (incl. Tracing, Replay) 89.45 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.42 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.59 kB - -
CDN Bundle - uncompressed 91.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.26 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.53 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 160.21 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 228.15 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 274.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 280 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.69 kB - -
@sentry/nextjs (client) 56.18 kB - -
@sentry/sveltekit (client) 51.74 kB - -
@sentry/core/server 40.5 kB - -
@sentry/core/browser 13.51 kB - -
@sentry/node 144.71 kB +0.06% +78 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.22 kB - -
@sentry/node - without tracing 93.21 kB +0.02% +14 B 🔺
@sentry/node - without channel injection 122.92 kB +0.07% +75 B 🔺
@sentry/aws-serverless 101.46 kB +0.01% +7 B 🔺
@sentry/cloudflare (withSentry) - minified 208.47 kB - -
@sentry/cloudflare (withSentry) 516.75 kB - -

View base workflow run

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RulaKhaled left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be gated on recordInputs or dataCollection.genAI

@isaacs
isaacs force-pushed the isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer branch from e652f6b to aea4552 Compare September 25, 2026 17:53
@isaacs

isaacs commented Sep 25, 2026

Copy link
Copy Markdown
Member Author

I’d bring this up in the agent tracing channel before merging

Good call! Pinged them for input.

@github-actions

Copy link
Copy Markdown
Contributor

👋 @mydea — Please review this PR when you get a chance!

@github-actions

Copy link
Copy Markdown
Contributor

👋 @andreiborza — Please review this PR when you get a chance!

@RulaKhaled RulaKhaled left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the prefix to our conventions please?

@isaacs

isaacs commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

@RulaKhaled

Could you add the prefix to our conventions please?

PR open: getsentry/sentry-conventions#662

@isaacs
isaacs force-pushed the isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer branch from e5e058e to 94d0f9e Compare October 2, 2026 03:55
isaacs added a commit to getsentry/sentry-conventions that referenced this pull request Oct 5, 2026
The Vercel AI integration in sentry-javascript records the
`experimental_telemetry.metadata` of an AI SDK call as
`vercel.ai.telemetry.metadata.<key>` span attributes. SDK v10 did
this through the AI SDK's own OTel spans. A fix in v11 restores it
for `ai` 4 to 6 (getsentry/sentry-javascript#24721).

The type is `any`. The AI SDK allows strings, numbers, booleans and
arrays of these as metadata values, and the SDK sends them unchanged.
The schema allows only one type per attribute, so `any` is the only
type that covers all of these values.

The docs content schema did not accept `any`, though
`schemas/attribute.schema.json` allows it, as of #273. No attribute
used `any` before.

Related: getsentry/sentry-javascript#24721

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@isaacs
isaacs force-pushed the isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer branch from 94d0f9e to aadceaa Compare October 5, 2026 18:29
… 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.

Values are cast to string, as discussed in the linked sentry-conventions
PR. If this causes a problem we can revisit, but all extant examples
found in the wild are strings already, so it is likely safe, and
extremely cheap.

fixes JS-3800
fixes #24720
Re: #24706
Re: getsentry/sentry-conventions#662

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@isaacs
isaacs force-pushed the isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer branch from aadceaa to 131bd44 Compare October 5, 2026 18:33
@isaacs
isaacs merged commit f469f76 into develop Oct 5, 2026
1011 of 1045 checks passed
@isaacs
isaacs deleted the isaacschlueter/js-3800-vercelaiintegration-experimental_telemetrymetadata-no-longer branch October 5, 2026 21:00
isaacs added a commit to getsentry/sentry-conventions that referenced this pull request Oct 6, 2026
…662)

The Vercel AI integration in sentry-javascript records the
`experimental_telemetry.metadata` of an AI SDK call as
`vercel.ai.telemetry.metadata.<key>` span attributes. SDK v10 did
this through the AI SDK's own OTel spans. A fix in v11 restores it
for `ai` 4 to 6 (getsentry/sentry-javascript#24721).

The type is `string`. The AI SDK also allows numbers, booleans and
arrays as metadata values, but in practice users pass strings. SDKs
convert other values to strings. The attribute stays open-ended on
purpose, because the AI SDK does not define the metadata keys.

Related: getsentry/sentry-javascript#24721

Co-Authored-By: Claude Opus 5.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.

vercelAIIntegration: experimental_telemetry.metadata no longer recorded on gen_ai spans (v11 regression, ai <= 6)

3 participants