-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(Tracing): Check for AI operation id to detect a vercelai span #18823
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
Conversation
| 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.')) { |
There was a problem hiding this comment.
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.
| 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.')) { |
There was a problem hiding this comment.
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.
| return; | ||
| } | ||
|
|
||
| // Check if this is a Vercel AI span by name pattern. |
There was a problem hiding this comment.
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)
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.
|
| 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.')) { |
There was a problem hiding this comment.
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.
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)