🪢 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
feat(blob-storage): skip observation export dedup for FINAL-skip projects (#15576)
Steffen Schmitz090dae27fc27
diff --git a/packages/shared/src/server/repositories/observations.ts b/packages/shared/src/server/repositories/observations.tsindex 3824fc897c..84c82892a4 100644--- a/packages/shared/src/server/repositories/observations.ts+++ b/packages/shared/src/server/repositories/observations.ts@@ -1714,6 +1714,7 @@ const buildObservationsForBlobStorageExportQuery = (minTimestamp: Date,maxTimestamp: Date,fieldGroups: ObservationFieldGroupFull[],+ skipDedup: boolean,) => {// core is always required (provides id, trace_id, start/end_time used for deduplication)const effectiveGroups = new Set<ObservationFieldGroupFull>([@@ -1728,6 +1729,10 @@ const buildObservationsForBlobStorageExportQuery = (LEGACY_OBSERVATION_EXPORT_SQL_OVERRIDES[column.field] ?? column.field,);+ // Dedup (latest event_ts per id/project_id/type) requires sorting the full+ // range before the first row can stream. shouldSkipObservationsFinal-gated+ // projects write observations exactly once, so the sort buys nothing there+ // and the query degrades to a pure streaming scan.const query = `SELECT${selectedColumns.join(",\n ")}@@ -1735,8 +1740,12 @@ const buildObservationsForBlobStorageExportQuery = (WHERE project_id = {projectId: String}AND start_time >= {minTimestamp: DateTime64(3)}AND start_time <= {maxTimestamp: DateTime64(3)}- ORDER BY event_ts DESC- LIMIT 1 BY id, project_id, type+ ${+ skipDedup+ ? ""+ : `ORDER BY event_ts DESC+ LIMIT 1 BY id, project_id, type`+ }`;return {@@ -1755,18 +1764,19 @@ const buildObservationsForBlobStorageExportQuery = (};};-export const getObservationsForBlobStorageExport = function (+export const getObservationsForBlobStorageExport = async function* (projectId: string,minTimestamp: Date,maxTimestamp: Date,fieldGroups: ObservationFieldGroupFull[] = [...OBSERVATION_FIELD_GROUPS_FULL],) {- return queryClickhouseStream<Record<string, unknown>>(+ yield* queryClickhouseStream<Record<string, unknown>>(buildObservationsForBlobStorageExportQuery(projectId,minTimestamp,maxTimestamp,fieldGroups,+ await shouldSkipObservationsFinal(projectId),),);};@@ -1774,18 +1784,19 @@ export const getObservationsForBlobStorageExport = function (// Raw-passthrough variant (LFE-10402): yields each row's unparsed JSONEachRow// text, skipping the per-row parse/enrich/serialize cycle. Price columns are// NOT added here — that enrichment is dropped on this path.-export const getObservationsForBlobStorageExportRaw = function (+export const getObservationsForBlobStorageExportRaw = async function* (projectId: string,minTimestamp: Date,maxTimestamp: Date,fieldGroups: ObservationFieldGroupFull[] = [...OBSERVATION_FIELD_GROUPS_FULL],) {- return queryClickhouseStreamRawText(+ yield* queryClickhouseStreamRawText(buildObservationsForBlobStorageExportQuery(projectId,minTimestamp,maxTimestamp,fieldGroups,+ await shouldSkipObservationsFinal(projectId),),);};@@ -1793,7 +1804,7 @@ export const getObservationsForBlobStorageExportRaw = function (// LFE-10463: FORMAT Parquet export — reuses the field-group-aware builder and// streams raw binary bytes to upload. Like raw passthrough, no JS enrichment, so// price columns are NOT added.-export const getObservationsForBlobStorageExportParquet = function (+export const getObservationsForBlobStorageExportParquet = async function (projectId: string,minTimestamp: Date,maxTimestamp: Date,@@ -1805,6 +1816,7 @@ export const getObservationsForBlobStorageExportParquet = function (minTimestamp,maxTimestamp,fieldGroups,+ await shouldSkipObservationsFinal(projectId),),format: "Parquet",clickhouseSettings: BLOB_EXPORT_PARQUET_CLICKHOUSE_SETTINGS,