Skip to content

feat(node): Update vercel ai integration attributes #16721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025

Conversation

AbhiPrasad
Copy link
Member

Make changes to the Vercel AI integration as per https://www.notion.so/sentry/Agent-Monitoring-SDK-differences-21c8b10e4b5d80bcab51f72ae1418ea8

AI summary:

Key Improvements:

  1. Eliminated duplicate attributes - Tool call and prompt attributes are now renamed instead of duplicated
  2. Added tool input/output support - New gen_ai.tool.input and gen_ai.tool.output attributes
  3. Auto-sets tool type - Automatically adds gen_ai.tool.type: 'function' for tool calls
  4. Better OpenTelemetry compliance - Cleaner attribute mapping following semantic conventions

Technical Changes:

  • Uses renameAttributeKey() consistently instead of duplicating attributes
  • Removes old ai.* attributes after creating new gen_ai.* ones

@AbhiPrasad AbhiPrasad requested review from ArthurKnaus and a team June 24, 2025 16:00
@AbhiPrasad AbhiPrasad self-assigned this Jun 24, 2025
@AbhiPrasad AbhiPrasad requested review from Lms24 and chargome and removed request for a team June 24, 2025 16:00
Copy link
Contributor

github-actions bot commented Jun 24, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB - -
@sentry/browser - with treeshaking flags 23.76 kB - -
@sentry/browser (incl. Tracing) 39.59 kB - -
@sentry/browser (incl. Tracing, Replay) 77.69 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.78 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 82.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 94.57 kB - -
@sentry/browser (incl. Feedback) 40.75 kB - -
@sentry/browser (incl. sendFeedback) 28.7 kB - -
@sentry/browser (incl. FeedbackAsync) 33.59 kB - -
@sentry/react 25.76 kB - -
@sentry/react (incl. Tracing) 41.58 kB - -
@sentry/vue 28.37 kB - -
@sentry/vue (incl. Tracing) 41.4 kB - -
@sentry/svelte 24.01 kB - -
CDN Bundle 25.5 kB - -
CDN Bundle (incl. Tracing) 39.6 kB - -
CDN Bundle (incl. Tracing, Replay) 75.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 80.96 kB - -
CDN Bundle - uncompressed 74.5 kB - -
CDN Bundle (incl. Tracing) - uncompressed 117.63 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 231.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 244.5 kB - -
@sentry/nextjs (client) 43.22 kB - -
@sentry/sveltekit (client) 40.04 kB - -
@sentry/node 162.02 kB +0.04% +54 B 🔺
@sentry/node - without tracing 98.64 kB -0.01% -1 B 🔽
@sentry/aws-serverless 124.4 kB -0.01% -1 B 🔽

View base workflow run

@AbhiPrasad AbhiPrasad force-pushed the abhi-vercel-ai-attribute-changes branch from 55520e2 to e3cfd57 Compare June 24, 2025 19:31
Copy link
Member

@ArthurKnaus ArthurKnaus left a comment

Choose a reason for hiding this comment

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

🙌 thx for the quick changes!

@mydea
Copy link
Member

mydea commented Jun 25, 2025

note: This may conflict with #16732, whatever we merge first needs to be adjusted accordingly!

@AbhiPrasad AbhiPrasad force-pushed the abhi-vercel-ai-attribute-changes branch from efdf029 to 6750b12 Compare July 2, 2025 18:39
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Span Attribute Modification Bug

The processToolCallSpan function incorrectly uses renameAttributeKey to modify a local attributes object, which is a snapshot of the span's data (from spanToJSON(span).data). This prevents the gen_ai.tool.name and gen_ai.tool.call.id attributes from being set on the actual span, unlike the previous direct span.setAttribute() calls. This also creates an inconsistency with other attributes correctly set on the span, and impacts the span's name update which relies on the gen_ai.tool.name attribute.

packages/core/src/utils/vercel-ai.ts#L118-L120

span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'gen_ai.execute_tool');
renameAttributeKey(attributes, AI_TOOL_CALL_NAME_ATTRIBUTE, 'gen_ai.tool.name');
renameAttributeKey(attributes, AI_TOOL_CALL_ID_ATTRIBUTE, 'gen_ai.tool.call.id');

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@AbhiPrasad AbhiPrasad merged commit 04ecbc3 into develop Jul 2, 2025
165 of 166 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-vercel-ai-attribute-changes branch July 2, 2025 19:51
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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy