Skip to content

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

chore: measure lookup hits in ingestion pipeline (#4787)

Max Deichmann76cfaf106974
diff --git a/worker/src/services/IngestionService/index.ts b/worker/src/services/IngestionService/index.ts
index d61851729a..84344147f4 100644
--- a/worker/src/services/IngestionService/index.ts
+++ b/worker/src/services/IngestionService/index.ts
@@ -35,6 +35,7 @@ import {
convertDateToClickhouseDateTime,
TraceUpsertQueue,
QueueJobs,
+ recordIncrement,
} from "@langfuse/shared/src/server";
import { tokenCount } from "../../features/tokenisation/usage";
@@ -181,6 +182,19 @@ export class IngestionService {
),
]);
+ if (postgresScoreRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "postgres",
+ object: "score",
+ });
+ }
+ if (clickhouseScoreRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "clickhouse",
+ object: "score",
+ });
+ }
+
const finalScoreRecord: ScoreRecordInsertType =
await this.mergeScoreRecords({
clickhouseScoreRecord,
@@ -236,6 +250,19 @@ export class IngestionService {
}),
]);
+ if (postgresTraceRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "postgres",
+ object: "trace",
+ });
+ }
+ if (clickhouseTraceRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "clickhouse",
+ object: "trace",
+ });
+ }
+
const finalTraceRecord = await this.mergeTraceRecords({
clickhouseTraceRecord,
postgresTraceRecord,
@@ -335,6 +362,19 @@ export class IngestionService {
this.getPrompt(projectId, observationEventList),
]);
+ if (postgresObservationRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "postgres",
+ object: "observation",
+ });
+ }
+ if (clickhouseObservationRecord) {
+ recordIncrement("langfuse.ingestion.lookup.hit", 1, {
+ store: "clickhouse",
+ object: "observation",
+ });
+ }
+
const observationRecords = this.mapObservationEventsToRecords({
observationEventList: timeSortedEvents,
projectId,