Skip to content

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

fix(otel): parse only trace io on trace update (#8003)

Hassieb Pakzad4de10298dcd9
diff --git a/web/src/features/otel/server/OtelIngestionProcessor.ts b/web/src/features/otel/server/OtelIngestionProcessor.ts
index aa2f1e63b3..ae10d52326 100644
--- a/web/src/features/otel/server/OtelIngestionProcessor.ts
+++ b/web/src/features/otel/server/OtelIngestionProcessor.ts
@@ -447,7 +447,7 @@ export class OtelIngestionProcessor {
};
// Create full trace for root spans or spans with trace updates
- if (isRootSpan || hasTraceUpdates) {
+ if (isRootSpan) {
trace = {
...trace,
name:
@@ -488,6 +488,44 @@ export class OtelIngestionProcessor {
};
}
+ if (hasTraceUpdates && !isRootSpan) {
+ trace = {
+ ...trace,
+ name: attributes[LangfuseOtelSpanAttributes.TRACE_NAME] as string,
+ metadata: {
+ ...resourceAttributeMetadata,
+ ...this.extractMetadata(attributes, "trace"),
+ ...(isLangfuseSDKSpans
+ ? {}
+ : { attributes: spanAttributesInMetadata }),
+ resourceAttributes,
+ scope: {
+ ...(scopeSpan.scope || {}),
+ attributes: scopeAttributes,
+ },
+ } as Record<string, string | Record<string, string | number>>,
+ version:
+ (attributes?.[LangfuseOtelSpanAttributes.VERSION] as string) ??
+ resourceAttributes?.["service.version"] ??
+ null,
+ release:
+ (attributes?.[LangfuseOtelSpanAttributes.RELEASE] as string) ??
+ resourceAttributes?.[LangfuseOtelSpanAttributes.RELEASE] ??
+ 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",
+ tags: this.extractTags(attributes),
+ environment: this.extractEnvironment(attributes, resourceAttributes),
+ input: attributes[LangfuseOtelSpanAttributes.TRACE_INPUT],
+ output: attributes[LangfuseOtelSpanAttributes.TRACE_OUTPUT],
+ };
+ }
+
if (isRootSpan) {
this.traceEventCounts.rootSpanClosed += 1;
} else if (hasTraceUpdates) {