From 4b9fa48c29a9191c19494edfb6a1b827e0cf1ad2 Mon Sep 17 00:00:00 2001 From: RulaKhaled Date: Mon, 29 Sep 2025 14:45:36 +0300 Subject: [PATCH] fix(core): Remove name.split('.') Check and Always Respect experimental_telemetry.functionId for Vercel AI gen spans --- packages/core/src/utils/vercel-ai/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/utils/vercel-ai/index.ts b/packages/core/src/utils/vercel-ai/index.ts index 4b317fe653d6..912dcaee3bc4 100644 --- a/packages/core/src/utils/vercel-ai/index.ts +++ b/packages/core/src/utils/vercel-ai/index.ts @@ -178,9 +178,10 @@ function processGenerateSpan(span: Span, name: string, attributes: SpanAttribute span.setAttribute('ai.pipeline.name', nameWthoutAi); span.updateName(nameWthoutAi); - // If a Telemetry name is set and it is a pipeline span, use that as the operation name + // If a telemetry name is set and the span represents a pipeline, use it as the operation name. + // This name can be set at the request level by adding `experimental_telemetry.functionId`. const functionId = attributes[AI_TELEMETRY_FUNCTION_ID_ATTRIBUTE]; - if (functionId && typeof functionId === 'string' && name.split('.').length - 1 === 1) { + if (functionId && typeof functionId === 'string') { span.updateName(`${nameWthoutAi} ${functionId}`); span.setAttribute('gen_ai.function_id', functionId); }