Skip to content

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

chore: add instrumentation to ingestion zod parsing (#3224)

Max Deichmann6b127bced02c
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.ts
index 5130c55093..ce1fa55dfa 100644
--- a/web/src/pages/api/public/ingestion.ts
+++ b/web/src/pages/api/public/ingestion.ts
@@ -35,6 +35,7 @@ import {
import {
sendToWorkerIfEnvironmentConfigured,
QueueJobs,
+ instrumentSync,
} from "@langfuse/shared/src/server";
import { randomUUID } from "crypto";
import { prisma } from "@langfuse/shared/src/db";
@@ -80,7 +81,10 @@ export default async function handler(
metadata: jsonSchema.nullish(),
});
- const parsedSchema = batchType.safeParse(req.body);
+ const parsedSchema = instrumentSync(
+ { name: "ingestion-zod-parse-unknown-batch-event" },
+ () => batchType.safeParse(req.body),
+ );
recordIncrement(
"ingestion_event",
@@ -116,7 +120,10 @@ export default async function handler(
const batch: (z.infer<typeof ingestionEvent> | undefined)[] =
parsedSchema.data.batch.map((event) => {
- const parsed = ingestionEvent.safeParse(event);
+ const parsed = instrumentSync(
+ { name: "ingestion-zod-parse-individual-event" },
+ () => ingestionEvent.safeParse(event),
+ );
if (!parsed.success) {
validationErrors.push({
id: