Skip to content

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

refactor(worker): replace compressed tag with source enum on blob export metrics (#14503)

Niklas Semmler387280643803
diff --git a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts
index a611aea4fc..3fe4a6c607 100644
--- a/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts
+++ b/worker/src/features/blobstorage/handleBlobStorageIntegrationProjectJob.ts
@@ -56,6 +56,43 @@ import { randomUUID } from "crypto";
import { SpanKind } from "@opentelemetry/api";
import { env, v4AllowPreviewOptIn } from "../../env";
+export const BlobExportFormat = {
+ JSON_RAW: "json-raw",
+ JSON_GZIP: "json-gzip",
+ CSV_RAW: "csv-raw",
+ CSV_GZIP: "csv-gzip",
+ JSONL_RAW: "jsonl-raw",
+ JSONL_GZIP: "jsonl-gzip",
+} as const;
+export type BlobExportFormat =
+ (typeof BlobExportFormat)[keyof typeof BlobExportFormat];
+
+const FORMAT_LOOKUP: Record<
+ BlobStorageIntegrationFileType,
+ { raw: BlobExportFormat; gzip: BlobExportFormat }
+> = {
+ [BlobStorageIntegrationFileType.JSON]: {
+ raw: BlobExportFormat.JSON_RAW,
+ gzip: BlobExportFormat.JSON_GZIP,
+ },
+ [BlobStorageIntegrationFileType.CSV]: {
+ raw: BlobExportFormat.CSV_RAW,
+ gzip: BlobExportFormat.CSV_GZIP,
+ },
+ [BlobStorageIntegrationFileType.JSONL]: {
+ raw: BlobExportFormat.JSONL_RAW,
+ gzip: BlobExportFormat.JSONL_GZIP,
+ },
+};
+
+function resolveBlobExportFormat(
+ fileType: BlobStorageIntegrationFileType,
+ compressed: boolean,
+): BlobExportFormat {
+ const entry = FORMAT_LOOKUP[fileType];
+ return compressed ? entry.gzip : entry.raw;
+}
+
export const BLOB_STORAGE_LAG_BUFFER_MS = 20 * 60 * 1000; // 20-minute lag buffer
export async function* enrichObservationStream(
@@ -626,11 +663,15 @@ const processBlobStorageExport = async (config: {
projectId: config.projectId,
});
+ const exportFormat = resolveBlobExportFormat(
+ config.fileType,
+ config.compressed,
+ );
const byteTags = {
table: config.table,
projectId: config.projectId,
path: passthroughEligible ? "passthrough" : "standard",
- compressed: compressedCounter ? "true" : "false",
+ source: exportFormat,
};
recordIncrement(
"langfuse.blob_export.serialized_bytes",
@@ -714,10 +755,14 @@ const processBlobStorageExport = async (config: {
: Math.max(0, totalUploadMs - finalChReadMs - finalEnrichMs);
span.setAttribute("blob.gzipCpuMs", finalGzipCpuMs);
span.setAttribute("blob.uploadWaitMs", finalUploadWaitMs);
+ const finalExportFormat = resolveBlobExportFormat(
+ config.fileType,
+ config.compressed,
+ );
const stageTags = {
table: config.table,
path: passthroughEligible ? "passthrough" : "standard",
- compressed: config.compressed ? "true" : "false",
+ source: finalExportFormat,
};
recordHistogram(
"langfuse.blob_export.ch_read_ms",