Skip to content

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

chore: use a distribution metric for langfuse.ingestion.count_files (#5164)

Steffen Schmitz83e1c5a3dfd4
diff --git a/packages/shared/src/server/instrumentation/index.ts b/packages/shared/src/server/instrumentation/index.ts
index a38de89191..62436369fd 100644
--- a/packages/shared/src/server/instrumentation/index.ts
+++ b/packages/shared/src/server/instrumentation/index.ts
@@ -226,6 +226,14 @@ export const recordHistogram = (
dd.dogstatsd.histogram(stat, value, tags);
};
+export const recordDistribution = (
+ stat: string,
+ value?: number | undefined,
+ tags?: { [tag: string]: string | number } | undefined,
+) => {
+ dd.dogstatsd.distribution(stat, value, tags);
+};
+
/**
* Converts a queue name to the matching datadog metric name.
* Consumer only needs to append the relevant suffix.
diff --git a/worker/src/queues/ingestionQueue.ts b/worker/src/queues/ingestionQueue.ts
index 10d16ad189..04b7fb41cc 100644
--- a/worker/src/queues/ingestionQueue.ts
+++ b/worker/src/queues/ingestionQueue.ts
@@ -12,7 +12,7 @@ import {
getClickhouseEntityType,
getCurrentSpan,
getQueue,
- recordHistogram,
+ recordDistribution,
} from "@langfuse/shared/src/server";
import { prisma } from "@langfuse/shared/src/db";
@@ -100,9 +100,13 @@ export const ingestionQueueProcessorBuilder = (
const eventFiles = await s3Client.listFiles(
`${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,
- });
+ recordDistribution(
+ "langfuse.ingestion.count_files_distribution",
+ eventFiles.length,
+ {
+ kind: clickhouseEntityType,
+ },
+ );
span?.setAttribute(
"langfuse.ingestion.event.count_files",
eventFiles.length,