Skip to content

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

chore: add experimentation execution time metrics (#4219)

Max Deichmann5c1f2202cd60
diff --git a/web/src/server/utils/checkClickhouseAccess.ts b/web/src/server/utils/checkClickhouseAccess.ts
index 6cc0ce597e..35b44aebe1 100644
--- a/web/src/server/utils/checkClickhouseAccess.ts
+++ b/web/src/server/utils/checkClickhouseAccess.ts
@@ -1,5 +1,9 @@
import { env } from "@/src/env.mjs";
-import { instrumentAsync, logger } from "@langfuse/shared/src/server";
+import {
+ instrumentAsync,
+ logger,
+ recordGauge,
+} from "@langfuse/shared/src/server";
import { type User } from "next-auth";
import * as opentelemetry from "@opentelemetry/api";
import { TRPCError } from "@trpc/server";
@@ -71,6 +75,13 @@ export const measureAndReturnApi = async <T, Y>(args: {
currentSpan?.setAttribute("pg-duration", pgDuration);
currentSpan?.setAttribute("ch-duration", chDuration);
+ recordGauge("langfuse.clickhouse_execution_time", chDuration, {
+ operation: args.operation,
+ });
+ recordGauge("langfuse.postgres_execution_time", pgDuration, {
+ operation: args.operation,
+ });
+
return env.LANGFUSE_RETURN_FROM_CLICKHOUSE === "true"
? chResult
: pgResult;