🪢 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
infra: instrument batch processing (#2884)
Max Deichmannd0a619af35fd
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.tsindex 6eafae5332..fc7eea1a5d 100644--- a/web/src/pages/api/public/ingestion.ts+++ b/web/src/pages/api/public/ingestion.ts@@ -48,6 +48,7 @@ import { redis } from "@langfuse/shared/src/server";import { isSigtermReceived } from "@/src/utils/shutdown";import { WorkerClient } from "@/src/server/api/services/WorkerClient";+import { instrumentAsync } from "@/src/utils/instrumentation";export const config = {api: {@@ -139,27 +140,29 @@ export default async function handler();}- const result = await handleBatch(- sortedBatch,- parsedSchema.data.metadata,- req,- authCheck,- );-- // send out REST requests to worker for all trace types- await sendToWorkerIfEnvironmentConfigured(- result.results,- authCheck.scope.projectId,- );+ instrumentAsync({ name: "handleBatch" }, async () => {+ const result = await handleBatch(+ sortedBatch,+ parsedSchema.data.metadata,+ req,+ authCheck,+ );- // in case we did not return early, we return the result here- if (env.LANGFUSE_ASYNC_INGESTION_PROCESSING === "false") {- handleBatchResult(- [...validationErrors, ...result.errors],+ // send out REST requests to worker for all trace types+ await sendToWorkerIfEnvironmentConfigured(result.results,- res,+ authCheck.scope.projectId,);- }++ // in case we did not return early, we return the result here+ if (env.LANGFUSE_ASYNC_INGESTION_PROCESSING === "false") {+ handleBatchResult(+ [...validationErrors, ...result.errors],+ result.results,+ res,+ );+ }+ });} catch (error: unknown) {if (!(error instanceof UnauthorizedError)) {console.error("error_handling_ingestion_event", error);