🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(otel): completion start time parsing to handle JSON stringified values (#9455)
Hassieb Pakzad23300f9db8cf
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.tsindex ff8d0ced9a..927e91d23c 100644--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts@@ -21,6 +21,7 @@ import { LangfuseOtelSpanAttributes } from "./attributes";import { ObservationTypeMapperRegistry } from "./ObservationTypeMapper";import { env } from "../../env";import { OtelIngestionQueue } from "../redis/otelIngestionQueue";+import { isValidDateString } from "./utils";// Type definitions for internal processor stateinterface TraceState {@@ -1569,9 +1570,16 @@ export class OtelIngestionProcessor {startTimeISO?: string,): string | null {try {- return attributes[+ const value = attributes[LangfuseOtelSpanAttributes.OBSERVATION_COMPLETION_START_TIME] as any;++ if (isValidDateString(value)) return value;++ // Older SDKs have double stringified timestamps that need JSON parsing+ // "\"2025-10-01T08:45:26.112648Z\""+ const parsed = JSON.parse(value);+ if (isValidDateString(parsed)) return parsed;} catch {// Fallthrough}diff --git a/packages/shared/src/server/otel/utils.ts b/packages/shared/src/server/otel/utils.tsnew file mode 100644index 0000000000..20ca5b372c--- /dev/null+++ b/packages/shared/src/server/otel/utils.ts@@ -0,0 +1,3 @@+export function isValidDateString(dateString: string): boolean {+ return !isNaN(new Date(dateString).getTime());+}