-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import { | |
| import type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes'; | ||
| import { | ||
| AI_MODEL_ID_ATTRIBUTE, | ||
| AI_OPERATION_ID_ATTRIBUTE, | ||
| AI_PROMPT_MESSAGES_ATTRIBUTE, | ||
| AI_PROMPT_TOOLS_ATTRIBUTE, | ||
| AI_RESPONSE_OBJECT_ATTRIBUTE, | ||
|
|
@@ -65,8 +66,9 @@ function onVercelAiSpanStart(span: Span): void { | |
| return; | ||
| } | ||
|
|
||
| // Check if this is a Vercel AI span by name pattern. | ||
| 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 commentThe reason will be displayed to describe this comment to others. Learn more. V6 streaming spans incorrectly marked as non-streamingMedium Severity The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V6 spans missing sentry.op attributeMedium Severity The
RulaKhaled marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. V6 spans missing op attribute after filter bypassMedium Severity The filter change at line 71 allows v6 spans with |
||
| return; | ||
| } | ||
|
|
||
|
|
||
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 byprocessGenerateSpaninstead ofprocessToolCallSpan. This breaks tool call error linking viatoolCallSpanMapand applies wrong attribute transformations.Additional Locations (1)
packages/core/src/tracing/vercel-ai/index.ts#L70-L75