Skip to content

Commit 7640856

Browse files
authored
fix(Tracing): Check for AI operation id to detect a vercelai span (#18823)
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)
1 parent f3097a3 commit 7640856

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/core/src/tracing/vercel-ai

packages/core/src/tracing/vercel-ai/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import type { OpenAiProviderMetadata, ProviderMetadata } from './vercel-ai-attributes';
2626
import {
2727
AI_MODEL_ID_ATTRIBUTE,
28+
AI_OPERATION_ID_ATTRIBUTE,
2829
AI_PROMPT_MESSAGES_ATTRIBUTE,
2930
AI_PROMPT_TOOLS_ATTRIBUTE,
3031
AI_RESPONSE_OBJECT_ATTRIBUTE,
@@ -65,8 +66,9 @@ function onVercelAiSpanStart(span: Span): void {
6566
return;
6667
}
6768

68-
// Check if this is a Vercel AI span by name pattern.
69-
if (!name.startsWith('ai.')) {
69+
// V6+ Check if this is a Vercel AI span by checking if the operation ID attribute is present.
70+
// V5+ Check if this is a Vercel AI span by name pattern.
71+
if (!attributes[AI_OPERATION_ID_ATTRIBUTE] && !name.startsWith('ai.')) {
7072
return;
7173
}
7274

0 commit comments

Comments
 (0)