Skip to content

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

fix(otel): parse trace name if as_root is true (#8008)

Hassieb Pakzadcf119fb9cc68
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
index 2d358dbdca..758f197ea0 100644
--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
@@ -486,7 +486,7 @@ describe("OTel Resource Span Mapping", () => {
expect(traceEvent.body).toMatchObject({
id: "95f3b926c7d009925bcb5dbc27311120",
timestamp: "2025-05-05T13:42:33.936Z",
- name: undefined,
+ name: "my-span-with-custom-trace-id",
environment: "production",
});
});
diff --git a/web/src/features/otel/server/OtelIngestionProcessor.ts b/web/src/features/otel/server/OtelIngestionProcessor.ts
index 2bda370de1..97cba0d0df 100644
--- a/web/src/features/otel/server/OtelIngestionProcessor.ts
+++ b/web/src/features/otel/server/OtelIngestionProcessor.ts
@@ -435,7 +435,6 @@ export class OtelIngestionProcessor {
isLangfuseSDKSpans,
isRootSpan,
hasTraceUpdates,
- parentObservationId,
span,
} = params;
@@ -452,9 +451,7 @@ export class OtelIngestionProcessor {
...trace,
name:
(attributes[LangfuseOtelSpanAttributes.TRACE_NAME] as string) ??
- (!parentObservationId
- ? this.extractName(span.name, attributes)
- : undefined),
+ this.extractName(span.name, attributes),
metadata: {
...resourceAttributeMetadata,
...this.extractMetadata(attributes, "trace"),
@@ -477,12 +474,7 @@ export class OtelIngestionProcessor {
null,
userId: this.extractUserId(attributes),
sessionId: this.extractSessionId(attributes),
- public:
- attributes?.[LangfuseOtelSpanAttributes.TRACE_PUBLIC] === true ||
- attributes?.[LangfuseOtelSpanAttributes.TRACE_PUBLIC] === "true" ||
- attributes?.["langfuse.public"] === true ||
- attributes?.["langfuse.public"] === "true" ||
- undefined,
+ public: this.isTracePublic(attributes),
tags: this.extractTags(attributes),
environment: this.extractEnvironment(attributes, resourceAttributes),
...this.extractInputAndOutput(span?.events ?? [], attributes, "trace"),
@@ -515,12 +507,7 @@ export class OtelIngestionProcessor {
null,
userId: this.extractUserId(attributes),
sessionId: this.extractSessionId(attributes),
- public:
- attributes?.[LangfuseOtelSpanAttributes.TRACE_PUBLIC] === true ||
- attributes?.[LangfuseOtelSpanAttributes.TRACE_PUBLIC] === "true" ||
- attributes?.["langfuse.public"] === true ||
- attributes?.["langfuse.public"] === "true" ||
- undefined,
+ public: this.isTracePublic(attributes),
tags: this.extractTags(attributes),
environment: this.extractEnvironment(attributes, resourceAttributes),
input: attributes[LangfuseOtelSpanAttributes.TRACE_INPUT],
@@ -544,6 +531,18 @@ export class OtelIngestionProcessor {
};
}
+ private isTracePublic(
+ attributes?: Record<string, unknown>,
+ ): boolean | undefined {
+ const value =
+ attributes?.[LangfuseOtelSpanAttributes.TRACE_PUBLIC] ??
+ attributes?.["langfuse.public"];
+
+ if (value == null) return;
+
+ return value === true || value === "true" ? true : false;
+ }
+
private createObservationEvent(
params: CreateObservationEventParams,
): IngestionEventType {