Skip to content

Commit 065ce1a

Browse files
authored
fix(tracing): Set span operations for AI spans with model ID only (#18471)
Fixes an issue where VercelAI integration span operations were not being set correctly because the validation was too restrictive. I relaxed the condition to only require `ai.model.id` attribute instead of both `ai.model.id` and `ai.model.provider` as provider attribute is optional and may not always be present on spans Closes https://linear.app/getsentry/issue/JS-1280
1 parent 5affac5 commit 065ce1a

File tree

1 file changed

+3
-6
lines changed
  • packages/core/src/tracing/vercel-ai

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
import type { ProviderMetadata } from './vercel-ai-attributes';
2525
import {
2626
AI_MODEL_ID_ATTRIBUTE,
27-
AI_MODEL_PROVIDER_ATTRIBUTE,
2827
AI_PROMPT_MESSAGES_ATTRIBUTE,
2928
AI_PROMPT_TOOLS_ATTRIBUTE,
3029
AI_RESPONSE_OBJECT_ATTRIBUTE,
@@ -65,12 +64,10 @@ function onVercelAiSpanStart(span: Span): void {
6564
return;
6665
}
6766

68-
// The AI and Provider must be defined for generate, stream, and embed spans.
69-
// The id of the model
67+
// The AI model ID must be defined for generate, stream, and embed spans.
68+
// The provider is optional and may not always be present.
7069
const aiModelId = attributes[AI_MODEL_ID_ATTRIBUTE];
71-
// the provider of the model
72-
const aiModelProvider = attributes[AI_MODEL_PROVIDER_ATTRIBUTE];
73-
if (typeof aiModelId !== 'string' || typeof aiModelProvider !== 'string' || !aiModelId || !aiModelProvider) {
70+
if (typeof aiModelId !== 'string' || !aiModelId) {
7471
return;
7572
}
7673

0 commit comments

Comments
 (0)