🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(otel): do not map vercel AI SDK spans to generation if no model info (#10148)
Hassieb Pakzadebf4ea3a5df3
diff --git a/packages/shared/src/server/otel/ObservationTypeMapper.ts b/packages/shared/src/server/otel/ObservationTypeMapper.tsindex 208c59c7de..f246dd0c77 100644--- a/packages/shared/src/server/otel/ObservationTypeMapper.ts+++ b/packages/shared/src/server/otel/ObservationTypeMapper.ts@@ -229,7 +229,23 @@ export class ObservationTypeMapperRegistry {new CustomAttributeMapper("Vercel_AI_SDK_Operation",4,- (attributes) => hasMeaningfulValue(attributes["operation.name"]),+ (attributes) => {+ const modelKeys = [+ LangfuseOtelSpanAttributes.OBSERVATION_MODEL,+ "gen_ai.request.model",+ "gen_ai.response.model",+ ];+ const hasModelInformation = modelKeys.some((key) =>+ hasMeaningfulValue(attributes[key]),+ );+ const hasOperationName = hasMeaningfulValue(+ attributes["operation.name"],+ );++ const isToolCall = Boolean(attributes["ai.toolCall"]);++ return (hasModelInformation && hasOperationName) || isToolCall;+ },(attributes) => {const operationName = attributes["operation.name"] as string;// Format:diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.tsindex b1d9e7549a..6100b4dfe2 100644--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts@@ -1234,6 +1234,10 @@ describe("OTel Resource Span Mapping", () => {key: "operation.name",value: { stringValue: operationName },},+ {+ key: "gen_ai.response.model",+ value: { stringValue: "gpt-4o" },+ },],},],