🪢 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
chore(ingestions): add s3 download size hist and span attribute (#7887)
Hassieb Pakzadd0c317b4232d
diff --git a/worker/src/queues/ingestionQueue.ts b/worker/src/queues/ingestionQueue.tsindex 836ab77905..4bcb889715 100644--- a/worker/src/queues/ingestionQueue.ts+++ b/worker/src/queues/ingestionQueue.ts@@ -9,6 +9,7 @@ import {logger,QueueName,recordDistribution,+ recordHistogram,recordIncrement,redis,TQueueJobTypes,@@ -143,12 +144,21 @@ export const ingestionQueueProcessorBuilder = (const s3Prefix = `${env.LANGFUSE_S3_EVENT_UPLOAD_PREFIX}${job.data.payload.authCheck.scope.projectId}/${clickhouseEntityType}/${job.data.payload.data.eventBodyId}/`;+ let totalS3DownloadSizeBytes = 0;+if (shouldSkipS3List) {// Direct file download - skip S3 list operationconst filePath = `${s3Prefix}${job.data.payload.data.fileKey}.json`;eventFiles = [{ file: filePath, createdAt: new Date() }];const file = await s3Client.download(filePath);+ const fileSize = file.length;++ recordHistogram("langfuse.ingestion.s3_file_size_bytes", fileSize, {+ skippedS3List: "true",+ });+ totalS3DownloadSizeBytes += fileSize;+const parsedFile = JSON.parse(file);events.push(...(Array.isArray(parsedFile) ? parsedFile : [parsedFile]));} else {@@ -158,6 +168,13 @@ export const ingestionQueueProcessorBuilder = (// If a user has 5k events, this will likely take 100 seconds.const downloadAndParseFile = async (fileRef: { file: string }) => {const file = await s3Client.download(fileRef.file);+ const fileSize = file.length;++ recordHistogram("langfuse.ingestion.s3_file_size_bytes", fileSize, {+ skippedS3List: "false",+ });+ totalS3DownloadSizeBytes += fileSize;+const parsedFile = JSON.parse(file);return Array.isArray(parsedFile) ? parsedFile : [parsedFile];};@@ -184,6 +201,10 @@ export const ingestionQueueProcessorBuilder = (eventFiles.length,);span?.setAttribute("langfuse.ingestion.event.kind", clickhouseEntityType);+ span?.setAttribute(+ "langfuse.ingestion.s3_all_files_size_bytes",+ totalS3DownloadSizeBytes,+ );const firstS3WriteTime =eventFiles