Skip to content

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

fix(otel): keep hex ids in place in id parsing (#7827)

Hassieb Pakzad3ba75e57a0cc
diff --git a/web/src/features/otel/server/OtelIngestionProcessor.ts b/web/src/features/otel/server/OtelIngestionProcessor.ts
index 3e6e903e8b..4e71501016 100644
--- a/web/src/features/otel/server/OtelIngestionProcessor.ts
+++ b/web/src/features/otel/server/OtelIngestionProcessor.ts
@@ -345,13 +345,9 @@ export class OtelIngestionProcessor {
const events: IngestionEventType[] = [];
const attributes = this.extractSpanAttributes(span);
- const traceId = Buffer.from(span.traceId?.data ?? span.traceId).toString(
- "hex",
- );
+ const traceId = this.parseId(span.traceId?.data ?? span.traceId);
const parentObservationId = span?.parentSpanId
- ? Buffer.from(span.parentSpanId?.data ?? span.parentSpanId).toString(
- "hex",
- )
+ ? this.parseId(span.parentSpanId?.data ?? span.parentSpanId)
: null;
const spanAttributeMetadata = this.extractMetadata(
@@ -528,7 +524,7 @@ export class OtelIngestionProcessor {
} = params;
const observation = {
- id: Buffer.from(span.spanId?.data ?? span.spanId).toString("hex"),
+ id: this.parseId(span.spanId?.data ?? span.spanId),
traceId,
parentObservationId,
name: this.extractName(span.name, attributes),
@@ -1272,9 +1268,7 @@ export class OtelIngestionProcessor {
resourceSpans.forEach((resourceSpan) => {
for (const scopeSpan of resourceSpan?.scopeSpans ?? []) {
for (const span of scopeSpan?.spans ?? []) {
- traceIds.add(
- Buffer.from(span.traceId?.data ?? span.traceId).toString("hex"),
- );
+ traceIds.add(this.parseId(span.traceId?.data ?? span.traceId));
}
}
});
@@ -1318,6 +1312,12 @@ export class OtelIngestionProcessor {
}
}
+ private parseId(data: any): string {
+ // JS SDK sends IDs already in hex strings
+ // Python SDK sends Int array
+ return typeof data === "string" ? data : Buffer.from(data).toString("hex");
+ }
+
/**
* Convert OpenTelemetry nano timestamp to ISO string.
* Handles various timestamp formats: string, number, or object with high/low bits.