Skip to content

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

fix: disable scores in CH PoC (#2822)

Hassieb Pakzadab997018ffa6
diff --git a/worker/src/env.ts b/worker/src/env.ts
index f86bd2e78a..fbe94817f9 100644
--- a/worker/src/env.ts
+++ b/worker/src/env.ts
@@ -40,7 +40,7 @@ const EnvSchema = z.object({
LANGFUSE_INGESTION_FLUSH_PROCESSING_CONCURRENCY: z.coerce
.number()
.positive()
- .default(50),
+ .default(100),
LANGFUSE_INGESTION_CLICKHOUSE_WRITE_BATCH_SIZE: z.coerce
.number()
.positive()
diff --git a/worker/src/queues/ingestionFlushQueue.ts b/worker/src/queues/ingestionFlushQueue.ts
index 9d0c57bbe7..174a2f0165 100644
--- a/worker/src/queues/ingestionFlushQueue.ts
+++ b/worker/src/queues/ingestionFlushQueue.ts
@@ -1,6 +1,7 @@
import { Queue, Worker } from "bullmq";
import { QueueJobs, QueueName } from "@langfuse/shared";
+import { prisma } from "@langfuse/shared/src/db";
import { clickhouseClient, redis } from "@langfuse/shared/src/server";
import * as Sentry from "@sentry/node";
diff --git a/worker/src/services/IngestionService/index.ts b/worker/src/services/IngestionService/index.ts
index c72b585492..ffa9e62cc9 100644
--- a/worker/src/services/IngestionService/index.ts
+++ b/worker/src/services/IngestionService/index.ts
@@ -102,10 +102,11 @@ export class IngestionService {
eventType: this.getEventType(event),
projectId,
});
+ const bufferKey = this.getBufferKey(projectEntityKey);
const serializedEventData = JSON.stringify({ ...event, projectId });
- await this.redis.lpush(projectEntityKey, serializedEventData);
- await this.redis.expire(projectEntityKey, this.bufferTtlSeconds);
+ await this.redis.lpush(bufferKey, serializedEventData);
+ await this.redis.expire(bufferKey, this.bufferTtlSeconds);
await this.ingestionFlushQueue.add(QueueJobs.FlushIngestionEntity, null, {
jobId: projectEntityKey,
});
@@ -115,7 +116,8 @@ export class IngestionService {
}
public async flush(projectEntityKey: string): Promise<void> {
- const eventList = (await this.redis.lrange(projectEntityKey, 0, -1))
+ const bufferKey = this.getBufferKey(projectEntityKey);
+ const eventList = (await this.redis.lrange(bufferKey, 0, -1))
.map((serializedEventData) => {
const parsed = ingestionEventWithProjectId.safeParse(
JSON.parse(serializedEventData)
@@ -156,11 +158,12 @@ export class IngestionService {
observationEventList: eventList as ObservationEvent[],
});
case EntityType.Score: {
- return await this.processScoreEventList({
- projectId,
- entityId,
- scoreEventList: eventList as ScoreEventType[],
- });
+ return; // TODO: refactor score validations and enable processing again
+ // return await this.processScoreEventList({
+ // projectId,
+ // entityId,
+ // scoreEventList: eventList as ScoreEventType[],
+ // });
}
}
}
@@ -193,27 +196,28 @@ export class IngestionService {
params.entityId
);
- return `ingestionBuffer_${params.projectId}_${params.eventType}_${sanitizedEntityId}`;
+ return `${params.projectId}_${params.eventType}_${sanitizedEntityId}`;
}
private parseProjectEntityKey(projectEntityKey: string) {
const split = projectEntityKey.split("_");
- if (split.length !== 4) {
+ if (split.length !== 3) {
throw new Error(
- `Invalid project entity key format ${projectEntityKey}, expected 4 parts`
+ `Invalid project entity key format ${projectEntityKey}, expected 3 parts`
);
}
- const projectId = split[1];
- const eventType = split[2] as EntityType;
- const escapedEntityId = split[3];
-
+ const [projectId, eventType, escapedEntityId] = split;
const entityId = IngestionService.unescapeReservedChars(escapedEntityId);
return { projectId, eventType, entityId };
}
+ private getBufferKey(projectEntityKey: string): string {
+ return "ingestionBuffer:" + projectEntityKey;
+ }
+
private static escapeReservedChars(string: string): string {
return reservedCharsEscapeMap.reduce(
(acc, { reserved, escape }) => acc.replaceAll(reserved, escape),