🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(blob-storage): Don't override storage engine if set (#10252)
Łukasz Jernaś8ed8e0f4f939
diff --git a/docker-compose.dev-azure.yml b/docker-compose.dev-azure.ymlindex 394965761f..cc0d6df157 100644--- a/docker-compose.dev-azure.yml+++ b/docker-compose.dev-azure.yml@@ -23,6 +23,29 @@ services:volumes:- langfuse_azurite_data:/data+ minio:+ image: docker.io/minio/minio+ container_name: ${MINIO_CONTAINER_NAME:-langfuse-minio}+ entrypoint: sh+ # create the 'langfuse' bucket before starting the service+ command: -c 'mkdir -p /data/langfuse && minio server --address ":9000" --console-address ":9001" /data'+ environment:+ MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minio}+ MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-miniosecret}+ ports:+ - ${HOST_IP:-127.0.0.1}:${MINIO_API_PORT:-9090}:9000+ - ${HOST_IP:-127.0.0.1}:${MINIO_CONSOLE_PORT:-9091}:9001+ volumes:+ - langfuse_minio_data:/data+ healthcheck:+ test: ["CMD", "mc", "ready", "local"]+ interval: 1s+ timeout: 5s+ retries: 5+ start_period: 1s+ networks:+ - default+redis:image: docker.io/redis:7.2.4restart: always@@ -60,3 +83,6 @@ volumes:driver: locallangfuse_azurite_data:driver: local+ langfuse_minio_data:+ name: ${MINIO_VOLUME_NAME:-langfuse_minio_data}+ driver: localdiff --git a/packages/shared/src/server/services/StorageService.ts b/packages/shared/src/server/services/StorageService.tsindex fb67db4a52..cbbebf01f1 100644--- a/packages/shared/src/server/services/StorageService.ts+++ b/packages/shared/src/server/services/StorageService.ts@@ -115,12 +115,17 @@ export class StorageServiceFactory {awsSse: string | undefined;awsSseKmsKeyId: string | undefined;}): StorageService {- if (params.useAzureBlob || env.LANGFUSE_USE_AZURE_BLOB === "true") {+ if (+ params.useAzureBlob !== undefined+ ? params.useAzureBlob+ : env.LANGFUSE_USE_AZURE_BLOB === "true"+ ) {return new AzureBlobStorageService(params);}if (- params.useGoogleCloudStorage ||- env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE === "true"+ params.useGoogleCloudStorage !== undefined+ ? params.useGoogleCloudStorage+ : env.LANGFUSE_USE_GOOGLE_CLOUD_STORAGE === "true") {// Use provided credentials or fall back to environment variableconst googleParams = {diff --git a/worker/src/__tests__/blobStorageIntegrationProcessing.test.ts b/worker/src/__tests__/blobStorageIntegrationProcessing.test.tsindex 876c8d0706..ce138bc3a7 100644--- a/worker/src/__tests__/blobStorageIntegrationProcessing.test.ts+++ b/worker/src/__tests__/blobStorageIntegrationProcessing.test.ts@@ -23,11 +23,15 @@ import { encrypt } from "@langfuse/shared/encryption";describe("BlobStorageIntegrationProcessingJob", () => {let storageService: StorageService;+ let s3StorageService: StorageService;const bucketName = env.LANGFUSE_S3_EVENT_UPLOAD_BUCKET || "";const accessKeyId = env.LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID || "";const secretAccessKey = env.LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY || "";const endpoint = env.LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT || undefined;const region = env.LANGFUSE_S3_EVENT_UPLOAD_REGION || undefined;+ const minioAccessKeyId = "minio";+ const minioAccessKeySecret = "miniosecret";+ const minioEndpoint = "http://localhost:9090";beforeAll(async () => {storageService = StorageServiceFactory.getInstance({@@ -38,6 +42,15 @@ describe("BlobStorageIntegrationProcessingJob", () => {region,forcePathStyle: env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",});+ s3StorageService = StorageServiceFactory.getInstance({+ accessKeyId: minioAccessKeyId,+ secretAccessKey: minioAccessKeySecret,+ bucketName,+ endpoint: minioEndpoint,+ region,+ forcePathStyle: true,+ useAzureBlob: false,+ });});it("should not process when blob storage integration is disabled", async () => {@@ -85,10 +98,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: "",- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -142,7 +155,7 @@ describe("BlobStorageIntegrationProcessingJob", () => {} as Job);// Then- const files = await storageService.listFiles("");+ const files = await s3StorageService.listFiles("");const projectFiles = files.filter((f) => f.file.includes(projectId));// Should have 3 files (traces, observations, scores)@@ -161,19 +174,19 @@ describe("BlobStorageIntegrationProcessingJob", () => {// Check file contentsif (traceFile) {- const content = await storageService.download(traceFile.file);+ const content = await s3StorageService.download(traceFile.file);expect(content).toContain(traceId);expect(content).toContain("Test Trace");}if (observationFile) {- const content = await storageService.download(observationFile.file);+ const content = await s3StorageService.download(observationFile.file);expect(content).toContain(observationId);expect(content).toContain("Test Observation");}if (scoreFile) {- const content = await storageService.download(scoreFile.file);+ const content = await s3StorageService.download(scoreFile.file);expect(content).toContain(scoreId);expect(content).toContain("Test Score");expect(content).toContain("0.95");@@ -209,10 +222,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: "",- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region,- endpoint: endpoint,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -272,10 +285,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix,- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -367,10 +380,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: `${fileType.toLowerCase()}-test/`,- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -386,7 +399,7 @@ describe("BlobStorageIntegrationProcessingJob", () => {} as Job);// Get files for this file type- const files = await storageService.listFiles("");+ const files = await s3StorageService.listFiles("");const projectFiles = files.filter((f) =>f.file.includes(projectId) &&@@ -404,7 +417,7 @@ describe("BlobStorageIntegrationProcessingJob", () => {// Check file contents for each typefor (const file of projectFiles) {- const content = await storageService.download(file.file);+ const content = await s3StorageService.download(file.file);// Verify content based on file typeif (file.file.includes("/traces/")) {@@ -602,10 +615,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: `${projectId}/test-custom/`,- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -620,7 +633,9 @@ describe("BlobStorageIntegrationProcessingJob", () => {data: { payload: { projectId } },} as Job);- const files = await storageService.listFiles(`${projectId}/test-custom/`);+ const files = await s3StorageService.listFiles(+ `${projectId}/test-custom/`,+ );const projectFiles = files.filter((f) => f.file.includes(projectId));const traceFile = projectFiles.find((f) => f.file.includes("/traces/"));@@ -628,7 +643,7 @@ describe("BlobStorageIntegrationProcessingJob", () => {// Should only include traces from custom date onwardsif (traceFile) {- const content = await storageService.download(traceFile.file);+ const content = await s3StorageService.download(traceFile.file);expect(content).not.toContain(oldTrace.id);expect(content).toContain(recentTrace.id);}@@ -737,10 +752,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: `${projectId}/test-catchup/`,- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,@@ -793,10 +808,10 @@ describe("BlobStorageIntegrationProcessingJob", () => {type: BlobStorageIntegrationType.S3,bucketName,prefix: `${projectId}/test-caught-up/`,- accessKeyId,- secretAccessKey: encrypt(secretAccessKey),+ accessKeyId: minioAccessKeyId,+ secretAccessKey: encrypt(minioAccessKeySecret),region: region ? region : "auto",- endpoint: endpoint ? endpoint : null,+ endpoint: minioEndpoint,forcePathStyle:env.LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE === "true",enabled: true,