Skip to content

Conversation

@RulaKhaled
Copy link
Member

@RulaKhaled RulaKhaled commented Jan 15, 2026

Resolves an issue where spans weren’t being processed because v6 emits spans with a "default" name. We now validate using both the span name (v5) and the operation ID (v6).

Closes #18824 (added automatically)

if (!name.startsWith('ai.')) {
// V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.
// V5+ Check if this is a Vercel AI span by name pattern.
if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {
Copy link

Choose a reason for hiding this comment

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

V6 streaming spans incorrectly marked as non-streaming

Medium Severity

The ai.streaming attribute is set based on name.includes('stream'), which relies on V5 naming conventions where span names contain "stream" (e.g., ai.streamText). For V6 spans with a "default" name, this check will always return false, causing streaming operations to be incorrectly marked as ai.streaming = false. The fix allows V6 spans to be processed, but this downstream logic wasn't updated to handle V6 naming.

Fix in Cursor Fix in Web

if (!name.startsWith('ai.')) {
// V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.
// V5+ Check if this is a Vercel AI span by name pattern.
if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {
Copy link

Choose a reason for hiding this comment

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

V6 spans missing sentry.op attribute

Medium Severity

The getSpanOpFromName(name) function relies on V5 naming conventions and returns undefined for V6 spans with non-standard names like "default". Since the op is only set when getSpanOpFromName returns a truthy value, V6 spans will not have SEMANTIC_ATTRIBUTE_SENTRY_OP set, which could affect span categorization and display in Sentry.

Fix in Cursor Fix in Web

return;
}

// Check if this is a Vercel AI span by name pattern.
Copy link

Choose a reason for hiding this comment

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

V6 tool call spans incorrectly processed as generate spans

High Severity

The tool call span check at line 64 requires name === 'ai.toolCall'. If V6 tool call spans also have "default" as their name (like other V6 spans), they will fail this check but pass the new V6 detection at line 71, causing them to be incorrectly processed by processGenerateSpan instead of processToolCallSpan. This breaks tool call error linking via toolCallSpanMap and applies wrong attribute transformations.

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,760 - 9,183 -5%
GET With Sentry 1,674 19% 1,540 +9%
GET With Sentry (error only) 5,960 68% 5,904 +1%
POST Baseline 1,184 - 1,154 +3%
POST With Sentry 576 49% 558 +3%
POST With Sentry (error only) 1,044 88% 1,027 +2%
MYSQL Baseline 3,292 - 3,215 +2%
MYSQL With Sentry 439 13% 367 +20%
MYSQL With Sentry (error only) 2,661 81% 2,542 +5%

View base workflow run

@RulaKhaled RulaKhaled enabled auto-merge (squash) January 15, 2026 17:30
if (!name.startsWith('ai.')) {
// V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.
// V5+ Check if this is a Vercel AI span by name pattern.
if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {
Copy link

Choose a reason for hiding this comment

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

V6 spans missing op attribute after filter bypass

Medium Severity

The filter change at line 71 allows v6 spans with AI_OPERATION_ID_ATTRIBUTE through, but processGenerateSpan still relies on the span name for determining the sentry.op via getSpanOpFromName(). For v6 spans with a "default" name, getSpanOpFromName('default') returns undefined, so no op attribute is set. Additionally, name.includes('stream') will always be false for "default" names, and the span name won't be updated with the model ID since the switch statement only matches ai.* patterns. The fix allows v6 spans through but doesn't update the processing logic to use AI_OPERATION_ID_ATTRIBUTE or OPERATION_NAME_ATTRIBUTE for determining span characteristics.

Fix in Cursor Fix in Web

@RulaKhaled RulaKhaled merged commit 7640856 into develop Jan 15, 2026
209 checks passed
@RulaKhaled RulaKhaled deleted the fix-ai-check branch January 15, 2026 17:41
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.

fix(Tracing): Check for AI operation id to detect a vercelai span

4 participants