Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function run() {
let callCount = 0;

const agent = new ToolLoopAgent({
experimental_telemetry: { isEnabled: true },
experimental_telemetry: { isEnabled: true, functionId: 'weather_agent' },
model: new MockLanguageModelV3({
doGenerate: async () => {
if (callCount++ === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ describe('Vercel AI integration (V6)', () => {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.vercelai.otel',
[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'mock-model-id',
}),
description: 'invoke_agent weather_agent',
op: 'gen_ai.invoke_agent',
origin: 'auto.vercelai.otel',
status: 'ok',
Expand All @@ -633,6 +634,7 @@ describe('Vercel AI integration (V6)', () => {
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 20,
[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE]: ['tool-calls'],
}),
description: 'generate_content mock-model-id',
op: 'gen_ai.generate_content',
origin: 'auto.vercelai.otel',
status: 'ok',
Expand Down Expand Up @@ -662,6 +664,7 @@ describe('Vercel AI integration (V6)', () => {
[GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE]: 25,
[GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE]: ['stop'],
}),
description: 'generate_content mock-model-id',
op: 'gen_ai.generate_content',
origin: 'auto.vercelai.otel',
status: 'ok',
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/tracing/vercel-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,13 @@ function processEndedVercelAiSpan(span: SpanJSON): void {
// Rename AI SDK attributes to standardized gen_ai attributes
// Map operation.name to OpenTelemetry semantic convention values
if (attributes[OPERATION_NAME_ATTRIBUTE]) {
const operationName = mapVercelAiOperationName(attributes[OPERATION_NAME_ATTRIBUTE] as string);
// V6+ sets ai.operationId to the bare operation (e.g. "ai.streamText") while
// operation.name appends functionId (e.g. "ai.streamText myAgent").
// When ai.operationId is present, use it for correct mapping.
const rawOperationName = attributes[AI_OPERATION_ID_ATTRIBUTE]
? (attributes[AI_OPERATION_ID_ATTRIBUTE] as string)
: (attributes[OPERATION_NAME_ATTRIBUTE] as string);
const operationName = mapVercelAiOperationName(rawOperationName);
attributes[GEN_AI_OPERATION_NAME_ATTRIBUTE] = operationName;
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete attributes[OPERATION_NAME_ATTRIBUTE];
Expand Down
Loading