Skip to content

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

perf: do not send empty events to worker (#1732)

Max Deichmann08d19a6d11b3
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.ts
index 8d920ea7b6..25ebba74c7 100644
--- a/web/src/pages/api/public/ingestion.ts
+++ b/web/src/pages/api/public/ingestion.ts
@@ -441,18 +441,20 @@ export const sendToWorkerIfEnvironmentConfigured = async (
)
.filter(isNotNullOrUndefined);
- await fetch(`${env.LANGFUSE_WORKER_HOST}/api/events`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization:
- "Basic " +
- Buffer.from("admin" + ":" + env.LANGFUSE_WORKER_PASSWORD).toString(
- "base64",
- ),
- },
- body: JSON.stringify(traceEvents),
- });
+ if (traceEvents.length > 0) {
+ await fetch(`${env.LANGFUSE_WORKER_HOST}/api/events`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization:
+ "Basic " +
+ Buffer.from(
+ "admin" + ":" + env.LANGFUSE_WORKER_PASSWORD,
+ ).toString("base64"),
+ },
+ body: JSON.stringify(traceEvents),
+ });
+ }
}
} catch (error) {
console.error("Error sending events to worker", error);