Skip to content

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

chore: rename db read stream (#9843)

Max Deichmann5e181559c86d
diff --git a/worker/src/__tests__/batchAction.test.ts b/worker/src/__tests__/batchAction.test.ts
index d8e9530ccd..f7f1aa790b 100644
--- a/worker/src/__tests__/batchAction.test.ts
+++ b/worker/src/__tests__/batchAction.test.ts
@@ -4,7 +4,7 @@ import { expect, describe, it, vi } from "vitest";
import { v4 as uuidv4 } from "uuid";
import { handleBatchActionJob } from "../features/batchAction/handleBatchActionJob";
import {
- getDatabaseReadStream,
+ getDatabaseReadStreamPaginated,
getTraceIdentifierStream,
} from "../features/database-read-stream/getDatabaseReadStream";
import {
@@ -56,7 +56,7 @@ describe("select all test suite", () => {
await handleBatchActionJob(selectAllJob);
// Verify traces were deleted
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date("2024-01-02"),
@@ -137,7 +137,7 @@ describe("select all test suite", () => {
await handleBatchActionJob(selectAllJob);
// Verify only filtered traces were processed
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date("2024-01-02"),
@@ -222,7 +222,7 @@ describe("select all test suite", () => {
await handleBatchActionJob(selectAllJob);
// Verify only the trace matching the search query was deleted
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date("2024-01-02"),
diff --git a/worker/src/__tests__/batchExport.test.ts b/worker/src/__tests__/batchExport.test.ts
index 02f02a2dbb..63b57a293a 100644
--- a/worker/src/__tests__/batchExport.test.ts
+++ b/worker/src/__tests__/batchExport.test.ts
@@ -11,7 +11,7 @@ import {
} from "@langfuse/shared/src/server";
import { BatchExportTableName, DatasetStatus } from "@langfuse/shared";
import { prisma } from "@langfuse/shared/src/db";
-import { getDatabaseReadStream } from "../features/database-read-stream/getDatabaseReadStream";
+import { getDatabaseReadStreamPaginated } from "../features/database-read-stream/getDatabaseReadStream";
import { getObservationStream } from "../features/database-read-stream/observation-stream";
describe("batch export test suite", () => {
@@ -209,7 +209,7 @@ describe("batch export test suite", () => {
await createScoresCh([score]);
await createObservationsCh(generations);
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Sessions,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -306,7 +306,7 @@ describe("batch export test suite", () => {
await createObservationsCh(generations);
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Sessions,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -404,7 +404,7 @@ describe("batch export test suite", () => {
await createScoresCh([score, qualitativeScore]);
await createObservationsCh(generations);
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -473,7 +473,7 @@ describe("batch export test suite", () => {
await createTracesCh(traces);
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date("2024-01-02"),
@@ -590,7 +590,7 @@ describe("batch export test suite", () => {
await createScoresCh(scores);
// Export scores with filter on name and sort by timestamp
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Scores,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -672,7 +672,7 @@ describe("batch export test suite", () => {
await createScoresCh(scores);
// Export all scores
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Scores,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -765,7 +765,7 @@ describe("batch export test suite", () => {
await createScoresCh(scores);
// Export scores with date range filter
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Scores,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -879,7 +879,7 @@ describe("batch export test suite", () => {
await createScoresCh(scores);
// Export scores with multiple filter conditions
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Scores,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -997,7 +997,7 @@ describe("batch export test suite", () => {
await prisma.datasetItem.createMany({ data: datasetItems });
// Export dataset items
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId,
tableName: BatchExportTableName.DatasetItems,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -1137,7 +1137,7 @@ describe("batch export test suite", () => {
await prisma.datasetItem.createMany({ data: datasetItems });
// Export dataset items
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId,
tableName: BatchExportTableName.DatasetItems,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -1238,7 +1238,7 @@ describe("batch export test suite", () => {
});
// Export audit logs
- const stream = await getDatabaseReadStream({
+ const stream = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.AuditLogs,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
@@ -1314,7 +1314,7 @@ describe("batch export test suite", () => {
await createTracesCh(traces);
- const streamByName = await getDatabaseReadStream({
+ const streamByName = await getDatabaseReadStreamPaginated({
projectId: projectId,
tableName: BatchExportTableName.Traces,
cutoffCreatedAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
diff --git a/worker/src/features/batchAction/handleBatchActionJob.ts b/worker/src/features/batchAction/handleBatchActionJob.ts
index 88a5e4ddf8..ef3f94b47e 100644
--- a/worker/src/features/batchAction/handleBatchActionJob.ts
+++ b/worker/src/features/batchAction/handleBatchActionJob.ts
@@ -13,7 +13,7 @@ import {
FilterCondition,
} from "@langfuse/shared";
import {
- getDatabaseReadStream,
+ getDatabaseReadStreamPaginated,
getTraceIdentifierStream,
} from "../database-read-stream/getDatabaseReadStream";
import { processClickhouseTraceDelete } from "../traces/processClickhouseTraceDelete";
@@ -183,7 +183,7 @@ export const handleBatchActionJob = async (
searchQuery: query.searchQuery ?? undefined,
searchType: query.searchType ?? ["id" as const],
})
- : await getDatabaseReadStream({
+ : await getDatabaseReadStreamPaginated({
projectId: projectId,
cutoffCreatedAt: new Date(cutoffCreatedAt),
filter: convertDatesInFiltersFromStrings(query.filter ?? []),
@@ -244,7 +244,7 @@ export const handleBatchActionJob = async (
searchType: query.searchType,
rowLimit: env.LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT,
}) // when reading from clickhouse, we only want to read the necessary identifiers.
- : await getDatabaseReadStream({
+ : await getDatabaseReadStreamPaginated({
projectId: projectId,
cutoffCreatedAt: new Date(cutoffCreatedAt),
filter: convertDatesInFiltersFromStrings(query.filter ?? []),
diff --git a/worker/src/features/batchExport/handleBatchExportJob.ts b/worker/src/features/batchExport/handleBatchExportJob.ts
index 9d184d83d7..eded5047fc 100644
--- a/worker/src/features/batchExport/handleBatchExportJob.ts
+++ b/worker/src/features/batchExport/handleBatchExportJob.ts
@@ -17,7 +17,7 @@ import {
getCurrentSpan,
} from "@langfuse/shared/src/server";
import { env } from "../../env";
-import { getDatabaseReadStream } from "../database-read-stream/getDatabaseReadStream";
+import { getDatabaseReadStreamPaginated } from "../database-read-stream/getDatabaseReadStream";
import { getObservationStream } from "../database-read-stream/observation-stream";
export const handleBatchExportJob = async (
@@ -96,7 +96,7 @@ export const handleBatchExportJob = async (
cutoffCreatedAt: jobDetails.createdAt,
...parsedQuery.data,
})
- : await getDatabaseReadStream({
+ : await getDatabaseReadStreamPaginated({
projectId,
cutoffCreatedAt: jobDetails.createdAt,
...parsedQuery.data,
diff --git a/worker/src/features/database-read-stream/getDatabaseReadStream.ts b/worker/src/features/database-read-stream/getDatabaseReadStream.ts
index 43a1624c4b..4adf704ebb 100644
--- a/worker/src/features/database-read-stream/getDatabaseReadStream.ts
+++ b/worker/src/features/database-read-stream/getDatabaseReadStream.ts
@@ -87,7 +87,7 @@ export const getChunkWithFlattenedScores = <
});
};
-export const getDatabaseReadStream = async ({
+export const getDatabaseReadStreamPaginated = async ({
projectId,
tableName,
filter,