Skip to content

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

infra: record exceptions of health endpoint (#2970)

Max Deichmannb23eaf3cd42c
diff --git a/web/src/pages/api/public/health.ts b/web/src/pages/api/public/health.ts
index 859747cf01..0ee89ae1f8 100644
--- a/web/src/pages/api/public/health.ts
+++ b/web/src/pages/api/public/health.ts
@@ -3,6 +3,7 @@ import { cors, runMiddleware } from "@/src/features/public-api/server/cors";
import { telemetry } from "@/src/features/telemetry";
import { isSigtermReceived } from "@/src/utils/shutdown";
import { prisma } from "@langfuse/shared/src/db";
+import { traceException } from "@langfuse/shared/src/server";
import { type NextApiRequest, type NextApiResponse } from "next";
export default async function handler(
@@ -65,12 +66,14 @@ export default async function handler(
}
} catch (e) {
console.log("Health check failed: db not available", e);
+ traceException(e);
return res.status(503).json({
status: "Database not available",
version: VERSION.replace("v", ""),
});
}
} catch (e) {
+ traceException(e);
console.log("Health check failed: ", e);
return res.status(503).json({
status: "Health check failed",
diff --git a/worker/src/api/index.ts b/worker/src/api/index.ts
index 9bd1b256ea..767b037a2f 100644
--- a/worker/src/api/index.ts
+++ b/worker/src/api/index.ts
@@ -25,6 +25,7 @@ router.get<{}, { status: string }>("/health", async (_req, res) => {
try {
await checkContainerHealth(res);
} catch (e) {
+ traceException(e);
logger.error(e, "Health check failed");
res.status(500).json({
status: "error",