🪢 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
perf(dual-write): clamp min start time to past day and optimize trace sorting (#13172)
Steffen Schmitz864055f59351
diff --git a/worker/src/env.ts b/worker/src/env.tsindex e99b80f199..4c3dd138e8 100644--- a/worker/src/env.ts+++ b/worker/src/env.ts@@ -277,6 +277,12 @@ const EnvSchema = z.object({.optional().transform((s) => (s ? s.split(",").map((id) => id.trim()) : [])),+ // Comma-separated list of project IDs to exclude from event propagation dual-write+ LANGFUSE_EVENT_PROPAGATION_EXCLUDE_PROJECT_IDS: z+ .string()+ .optional()+ .transform((s) => (s ? s.split(",").map((id) => id.trim()) : [])),+// Core data S3 upload - Langfuse CloudLANGFUSE_S3_CORE_DATA_EXPORT_IS_ENABLED: z.enum(["true", "false"])diff --git a/worker/src/features/eventPropagation/handleEventPropagationJob.ts b/worker/src/features/eventPropagation/handleEventPropagationJob.tsindex 93a04ecedf..aff61ed6ec 100644--- a/worker/src/features/eventPropagation/handleEventPropagationJob.ts+++ b/worker/src/features/eventPropagation/handleEventPropagationJob.ts@@ -131,16 +131,23 @@ export const handleEventPropagationJob = async (// for the same span, this may create duplicates in the new events table. Deduplicating in this query// will significantly affect run-time. This may be an accepted degradation and we test the outcome// to check the likelihood of this happening in practice.+ const excludeProjectIds =+ env.LANGFUSE_EVENT_PROPAGATION_EXCLUDE_PROJECT_IDS;+ const excludeProjectIdsInClause =+ excludeProjectIds.length > 0+ ? `NOT IN (${excludeProjectIds.map((id) => `'${id}'`).join(",")})`+ : "";await commandClickhouse({query: `with batch_stats as (selectgroupUniqArray(project_id) as project_ids,groupUniqArray(trace_id) as trace_ids,- min(start_time) as min_start_time,+ minIf(start_time, start_time > now() - interval 1 day) as min_start_time,max(start_time) as max_start_timefrom observations_batch_stagingwhere _partition_value = tuple('${partitionToProcess}')+ ${excludeProjectIdsInClause ? `AND project_id ${excludeProjectIdsInClause}` : ""}), experiment_traces_to_exclude as (select distinctproject_id,@@ -171,7 +178,7 @@ export const handleEventPropagationJob = async (t.timestamp >= greatest((select min(min_start_time) - interval 1 day from batch_stats), now() - interval 7 day))and t.timestamp <= (select max(max_start_time) + interval 1 day from batch_stats)- order by t.event_ts desc+ order by t.project_id, t.id, t.event_ts desclimit 1 by t.project_id, t.id)@@ -291,6 +298,7 @@ export const handleEventPropagationJob = async (excl.trace_id = obs.trace_id)WHERE obs._partition_value = tuple('${partitionToProcess}')+ ${excludeProjectIdsInClause ? `AND obs.project_id ${excludeProjectIdsInClause}` : ""}`,tags: {feature: "ingestion",