Skip to content

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

fix: fixing bullmq config for BatchProjectDelete. removing accidentally commited dataModel changes. (#11551)

Valery Meleshkina16f4a0526da
diff --git a/packages/shared/src/server/queues.ts b/packages/shared/src/server/queues.ts
index d5eb9b9cea..b71fdac5cc 100644
--- a/packages/shared/src/server/queues.ts
+++ b/packages/shared/src/server/queues.ts
@@ -197,8 +197,16 @@ export const DeadLetterRetryQueueEventSchema = z.object({
timestamp: z.date(),
});
+export const BATCH_DELETION_TABLES = [
+ "traces",
+ "observations",
+ "scores",
+ "events",
+ "dataset_run_items_rmt",
+] as const;
+
export const BatchProjectCleanerJobSchema = z.object({
- table: z.enum(["traces", "observations", "scores", "events"]),
+ table: z.enum(BATCH_DELETION_TABLES),
});
export type BatchProjectCleanerJobType = z.infer<
typeof BatchProjectCleanerJobSchema
diff --git a/web/src/features/query/dataModel.ts b/web/src/features/query/dataModel.ts
index 12e258dcdd..adc7b93684 100644
--- a/web/src/features/query/dataModel.ts
+++ b/web/src/features/query/dataModel.ts
@@ -1198,28 +1198,6 @@ export const eventsObservationsView: ViewDeclarationType = {
description: "Time to first token for the observation.",
unit: "millisecond",
},
- tracesCount: {
- sql: "uniq(events.trace_id)",
- alias: "tracesCount",
- type: "integer",
- description: "Unique traces.",
- unit: "observations",
- },
- uniqueUserIds: {
- sql: "uniq(events.user_id)",
- alias: "uniqueUserIds",
- type: "integer",
- description: "Count of unique userIds.",
- unit: "users",
- },
- uniqueSessionIds: {
- sql: "uniq(events.session_id)",
- alias: "uniqueSessionIds",
- type: "integer",
- description: "Count of unique sessionIds.",
- unit: "sessions",
- },
- // TODO trace sessions
countScores: {
sql: "uniq(scores.id)",
alias: "countScores",
diff --git a/worker/src/app.ts b/worker/src/app.ts
index aa234d0b96..a799da0dec 100644
--- a/worker/src/app.ts
+++ b/worker/src/app.ts
@@ -38,6 +38,7 @@ import {
CloudFreeTierUsageThresholdQueue,
EventPropagationQueue,
BatchProjectCleanerQueue,
+ BATCH_DELETION_TABLES,
} from "@langfuse/shared/src/server";
import { env } from "./env";
import { ingestionQueueProcessorBuilder } from "./queues/ingestionQueue";
@@ -75,7 +76,6 @@ import { otelIngestionQueueProcessor } from "./queues/otelIngestionQueue";
import { eventPropagationProcessor } from "./queues/eventPropagationQueue";
import { notificationQueueProcessor } from "./queues/notificationQueue";
import { MutationMonitor } from "./features/mutation-monitoring/mutationMonitor";
-import { BATCH_DELETION_TABLES } from "./features/batch-project-cleaner";
import { batchProjectCleanerProcessor } from "./queues/batchProjectCleanerQueue";
const app = express();
@@ -549,7 +549,13 @@ if (env.LANGFUSE_BATCH_PROJECT_CLEANER_ENABLED === "true") {
WorkerManager.register(
QueueName.BatchProjectCleanerQueue,
batchProjectCleanerProcessor,
- { concurrency: 1 }, // only 1 job at a time
+ {
+ concurrency: 1, // only 1 job at a time per process.
+ limiter: {
+ max: 1,
+ duration: env.LANGFUSE_BATCH_PROJECT_CLEANER_SLEEP_ON_EMPTY_MS, // no more than 1 job at a time globally
+ },
+ },
);
// Schedule repeatable jobs for each table
diff --git a/worker/src/features/batch-project-cleaner/index.ts b/worker/src/features/batch-project-cleaner/index.ts
index 1b2eda6da6..f692345c1b 100644
--- a/worker/src/features/batch-project-cleaner/index.ts
+++ b/worker/src/features/batch-project-cleaner/index.ts
@@ -4,18 +4,11 @@ import {
commandClickhouse,
traceException,
recordIncrement,
+ BATCH_DELETION_TABLES,
} from "@langfuse/shared/src/server";
import { prisma } from "@langfuse/shared/src/db";
import { env } from "../../env";
-export const BATCH_DELETION_TABLES = [
- "traces",
- "observations",
- "scores",
- "events",
- "dataset_run_items_rmt",
-] as const;
-
export type BatchDeletionTable = (typeof BATCH_DELETION_TABLES)[number];
interface ProjectCount {