🪢 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
chore(flushQueue): add logs (#2843)
Hassieb Pakzadc2bc17d4d183
diff --git a/worker/src/queues/ingestionFlushQueue.ts b/worker/src/queues/ingestionFlushQueue.tsindex 8b00ae0ec7..cb9a2d63fe 100644--- a/worker/src/queues/ingestionFlushQueue.ts+++ b/worker/src/queues/ingestionFlushQueue.ts@@ -51,46 +51,59 @@ export const flushIngestionQueueExecutor = redis});- // Check dependencies- if (!redis) throw new Error("Redis not available");- if (!prisma) throw new Error("Prisma not available");- if (!ingestionFlushQueue)- throw new Error("Ingestion flush queue not available");+ try {+ // Check dependencies+ if (!redis) throw new Error("Redis not available");+ if (!prisma) throw new Error("Prisma not available");+ if (!ingestionFlushQueue)+ throw new Error("Ingestion flush queue not available");- // Flush ingestion buffer- const processingStartTime = Date.now();+ // Flush ingestion buffer+ const processingStartTime = Date.now();- await new IngestionService(- redis,- prisma,- ingestionFlushQueue,- ClickhouseWriter.getInstance(),- clickhouseClient,- env.LANGFUSE_INGESTION_BUFFER_TTL_SECONDS- ).flush(projectEntityId);+ await new IngestionService(+ redis,+ prisma,+ ingestionFlushQueue,+ ClickhouseWriter.getInstance(),+ clickhouseClient,+ env.LANGFUSE_INGESTION_BUFFER_TTL_SECONDS+ ).flush(projectEntityId);- // Log processing time- const processingTime = Date.now() - processingStartTime;- logger.debug(- `Prepared and scheduled CH-write in ${processingTime} ms for ${projectEntityId}`- );- Sentry.metrics.distribution(- "ingestion_flush_processing_time",- processingTime,- { unit: "milliseconds" }- );+ // Log processing time+ const processingTime = Date.now() - processingStartTime;+ logger.debug(+ `Prepared and scheduled CH-write in ${processingTime} ms for ${projectEntityId}`+ );+ Sentry.metrics.distribution(+ "ingestion_flush_processing_time",+ processingTime,+ { unit: "milliseconds" }+ );++ // Log queue size+ await ingestionFlushQueue+ .count()+ .then((count) => {+ logger.debug(`Ingestion flush queue length: ${count}`);+ Sentry.metrics.gauge(+ "ingestion_flush_queue_length",+ count,+ {+ unit: "records",+ }+ );+ return count;+ })+ .catch();+ } catch (err) {+ console.error(+ `Error processing flush request for ${projectEntityId}`,+ err+ );- // Log queue size- await ingestionFlushQueue- .count()- .then((count) => {- logger.debug(`Ingestion flush queue length: ${count}`);- Sentry.metrics.gauge("ingestion_flush_queue_length", count, {- unit: "records",- });- return count;- })- .catch();+ throw err;+ }}});