Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: map langfuse data model to further otel attributes (#5614)

Steffen Schmitz485dc944447f
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
index 5062d6fbc5..cbb68ac63e 100644
--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
@@ -333,6 +333,36 @@ describe("OTel Resource Span Mapping", () => {
};
it.each([
+ [
+ "should extract promptName on observation from langfuse.prompt.name",
+ {
+ entity: "observation",
+ otelAttributeKey: "langfuse.prompt.name",
+ otelAttributeValue: { stringValue: "test" },
+ entityAttributeKey: "promptName",
+ entityAttributeValue: "test",
+ },
+ ],
+ [
+ "should extract public on trace from langfuse.public",
+ {
+ entity: "trace",
+ otelAttributeKey: "langfuse.public",
+ otelAttributeValue: { boolValue: true },
+ entityAttributeKey: "public",
+ entityAttributeValue: true,
+ },
+ ],
+ [
+ "should not treat truthy values as public true",
+ {
+ entity: "trace",
+ otelAttributeKey: "langfuse.public",
+ otelAttributeValue: { stringValue: "false" },
+ entityAttributeKey: "public",
+ entityAttributeValue: false,
+ },
+ ],
[
"should extract userId on trace from user.id",
{
diff --git a/web/src/features/otel/server/index.ts b/web/src/features/otel/server/index.ts
index 290f56d265..4d318e35ff 100644
--- a/web/src/features/otel/server/index.ts
+++ b/web/src/features/otel/server/index.ts
@@ -316,9 +316,17 @@ export const convertOtelSpanToIngestionEvent = (
resourceAttributes,
scope: scopeSpan?.scope,
},
- version: resourceAttributes?.["service.version"] ?? null,
+ version:
+ attributes?.["langfuse.version"] ??
+ resourceAttributes?.["service.version"] ??
+ null,
+ release: attributes?.["langfuse.release"] ?? null,
userId: extractUserId(attributes),
sessionId: extractSessionId(attributes),
+ public:
+ attributes?.["langfuse.public"] === true ||
+ attributes?.["langfuse.public"] === "true",
+ tags: attributes?.["langfuse.tags"] ?? [],
// Input and Output
...extractInputAndOutput(span?.events ?? [], attributes),
@@ -356,9 +364,17 @@ export const convertOtelSpanToIngestionEvent = (
span.status?.code === 2
? ObservationLevel.ERROR
: ObservationLevel.DEFAULT,
+ statusMessage: span.status?.message ?? null,
+ version:
+ attributes?.["langfuse.version"] ??
+ resourceAttributes?.["service.version"] ??
+ null,
modelParameters: extractModelParameters(attributes) as any,
model: extractModelName(attributes),
+ promptName: attributes?.["langfuse.prompt.name"] ?? null,
+ promptVersion: attributes?.["langfuse.prompt.version"] ?? null,
+
usageDetails: extractUsageDetails(attributes) as any,
costDetails: extractCostDetails(attributes) as any,