Skip to content

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

chore: add additional metrics into ingestion pipeline (#5160)

Steffen Schmitz5efcef593f09
diff --git a/worker/src/queues/ingestionQueue.ts b/worker/src/queues/ingestionQueue.ts
index 1601da2153..10d16ad189 100644
--- a/worker/src/queues/ingestionQueue.ts
+++ b/worker/src/queues/ingestionQueue.ts
@@ -12,6 +12,7 @@ import {
getClickhouseEntityType,
getCurrentSpan,
getQueue,
+ recordHistogram,
} from "@langfuse/shared/src/server";
import { prisma } from "@langfuse/shared/src/db";
@@ -93,9 +94,20 @@ export const ingestionQueueProcessorBuilder = (
);
// Download all events from folder into a local array
+ const clickhouseEntityType = getClickhouseEntityType(
+ job.data.payload.data.type,
+ );
const eventFiles = await s3Client.listFiles(
- `${env.LANGFUSE_S3_EVENT_UPLOAD_PREFIX}${job.data.payload.authCheck.scope.projectId}/${getClickhouseEntityType(job.data.payload.data.type)}/${job.data.payload.data.eventBodyId}/`,
+ `${env.LANGFUSE_S3_EVENT_UPLOAD_PREFIX}${job.data.payload.authCheck.scope.projectId}/${clickhouseEntityType}/${job.data.payload.data.eventBodyId}/`,
+ );
+ recordHistogram("langfuse.ingestion.count_files", eventFiles.length, {
+ kind: clickhouseEntityType,
+ });
+ span?.setAttribute(
+ "langfuse.ingestion.event.count_files",
+ eventFiles.length,
);
+ span?.setAttribute("langfuse.ingestion.event.kind", clickhouseEntityType);
const firstS3WriteTime =
eventFiles
diff --git a/worker/src/services/IngestionService/index.ts b/worker/src/services/IngestionService/index.ts
index a82faf9bf7..45993476a3 100644
--- a/worker/src/services/IngestionService/index.ts
+++ b/worker/src/services/IngestionService/index.ts
@@ -816,8 +816,16 @@ export class IngestionService {
};
}) {
if (await this.shouldSkipClickHouseRead(params.projectId)) {
+ recordIncrement("langfuse.ingestion.clickhouse_read_for_update", 1, {
+ skipped: "true",
+ table: params.table,
+ });
return null;
}
+ recordIncrement("langfuse.ingestion.clickhouse_read_for_update", 1, {
+ skipped: "false",
+ table: params.table,
+ });
const recordParser = {
traces: traceRecordReadSchema,