Skip to content

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

fix: skip JSON parsing for completion start time strings (#9418)

Steffen Schmitzc084d19c2d24
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
index 1f788cba55..f40ebaa933 100644
--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts
+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
@@ -1569,11 +1569,9 @@ export class OtelIngestionProcessor {
startTimeISO?: string,
): string | null {
try {
- return JSON.parse(
- attributes[
- LangfuseOtelSpanAttributes.OBSERVATION_COMPLETION_START_TIME
- ] as string,
- );
+ return attributes[
+ LangfuseOtelSpanAttributes.OBSERVATION_COMPLETION_START_TIME
+ ] as any;
} catch {
// Fallthrough
}
diff --git a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
index abbf3f5d08..14b5180034 100644
--- a/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
+++ b/web/src/__tests__/server/api/otel/otelMapping.servertest.ts
@@ -1525,6 +1525,18 @@ describe("OTel Resource Span Mapping", () => {
});
it.each([
+ [
+ "should cast input_tokens from string to number",
+ {
+ entity: "observation",
+ otelAttributeKey: "langfuse.observation.completion_start_time",
+ otelAttributeValue: {
+ stringValue: "2025-09-17T22:16:28.152000+02:00",
+ },
+ entityAttributeKey: "completionStartTime",
+ entityAttributeValue: "2025-09-17T22:16:28.152000+02:00",
+ },
+ ],
[
"should cast input_tokens from string to number",
{