From cd4cb154789bc8335bf4b2a322e2bb82964b5f08 Mon Sep 17 00:00:00 2001 From: Hengfei Yang Date: Mon, 12 Oct 2026 07:10:21 +0000 Subject: [PATCH] chore(alerts): remove commented-out RCA batch code and stale _meta history comments (#15253) --- .../management/src/request/alerts/history.rs | 1 - .../src/request/pipelines/history.rs | 4 +- src/core/src/alerts/scheduler/handlers.rs | 65 ------------------- src/core/src/alerts/scheduler/worker.rs | 15 ----- 4 files changed, 1 insertion(+), 84 deletions(-) diff --git a/src/api/management/src/request/alerts/history.rs b/src/api/management/src/request/alerts/history.rs index ff0a5d011a..665a4f6809 100644 --- a/src/api/management/src/request/alerts/history.rs +++ b/src/api/management/src/request/alerts/history.rs @@ -556,7 +556,6 @@ pub async fn get_alert_history( } }; - // Build SQL WHERE clause for the _meta organization's triggers stream. // Composites publish with module = "composite" and share the ordinary // alert outcome vocabulary, so include them in the same history read. let mut where_clause = format!( diff --git a/src/api/pipelines/src/request/pipelines/history.rs b/src/api/pipelines/src/request/pipelines/history.rs index 341d62fd85..85d1c970bf 100644 --- a/src/api/pipelines/src/request/pipelines/history.rs +++ b/src/api/pipelines/src/request/pipelines/history.rs @@ -107,7 +107,7 @@ pub struct PipelineHistoryResponse { tag = "Pipelines", operation_id = "GetPipelineHistory", summary = "Get pipeline execution history", - description = "Retrieves the execution history of pipelines for the organization. This endpoint queries the _meta organization's triggers stream to provide details about when pipelines were triggered, their status, and execution details.", + description = "Retrieves the execution history of pipelines for the organization. This endpoint queries the organization's own triggers stream to provide details about when pipelines were triggered, their status, and execution details.", security( ("Authorization"= []) ), @@ -350,7 +350,6 @@ pub async fn get_pipeline_history( } }; - // Build SQL WHERE clause for the _meta organization's triggers stream let mut where_clause = format!( "(module in ('derived_stream', 'pipeline')) AND org = '{org_id}' AND _timestamp >= {start_time} AND _timestamp <= {end_time}" ); @@ -480,7 +479,6 @@ pub async fn get_pipeline_history( ..Default::default() }; - // Execute search against _meta organization's triggers stream let search_result = match SearchService::search( &trace_id, &org_id, diff --git a/src/core/src/alerts/scheduler/handlers.rs b/src/core/src/alerts/scheduler/handlers.rs index 13b1a823f1..f5564ccab7 100644 --- a/src/core/src/alerts/scheduler/handlers.rs +++ b/src/core/src/alerts/scheduler/handlers.rs @@ -2247,37 +2247,6 @@ async fn handle_alert_triggers( // Set the is_realtime field according to the alert new_trigger.is_realtime = alert.is_real_time; - // [ENTERPRISE] Initialize RCA batch tracking for this scheduler run - // #[cfg(feature = "enterprise")] - // let rca_enabled = - // o2_enterprise::enterprise::ai::rca::integration::is_rca_enabled_for_org(&new_trigger. - // org); #[cfg(not(feature = "enterprise"))] - let _rca_enabled = false; - - // Helper closure to mark alert completion and process batch if needed - // #[cfg(feature = "enterprise")] - // let mark_rca_completion = || async { - // if rca_enabled { - // let is_batch_complete = - // o2_enterprise::enterprise::ai::rca::mark_alert_completed(trace_id); - // if is_batch_complete { - // log::info!( - // "[SCHEDULER trace_id {scheduler_trace_id}] Batch {} complete, processing - // incidents", trace_id - // ); - // if let Err(e) = - // o2_enterprise::enterprise::ai::rca::integration::process_batch_and_create_incidents( - // trace_id - // ).await { - // log::error!( - // "[SCHEDULER trace_id {scheduler_trace_id}] Error creating incidents from - // batch {}: {}", trace_id, e - // ); - // } - // } - // } - // }; - #[cfg(feature = "cloud")] { if !is_org_in_free_trial_period(&trigger.org).await? { @@ -2594,10 +2563,6 @@ async fn handle_alert_triggers( } publish_triggers_usage(trigger_data_stream); - // [ENTERPRISE] Mark completion even on failure - // #[cfg(feature = "enterprise")] - // mark_rca_completion().await; - return Err(err); } @@ -3201,32 +3166,6 @@ async fn handle_alert_triggers( } }; - // [ENTERPRISE] Collect alert events for batched incident creation - // #[cfg(feature = "enterprise")] - // if rca_enabled && !data.is_empty() { - // // Collect each deduplicated result row as an alert event - // // Use parent trace_id for cross-alert correlation (not scheduler_trace_id) - // for row in &data { - // if let Err(e) = - // o2_enterprise::enterprise::ai::rca::integration::collect_alert_event( - // trace_id, // Use parent trace_id for cross-alert batch &alert, - // row, - // triggered_at, - // ) { - // log::error!( - // "[SCHEDULER trace_id {scheduler_trace_id}] Error collecting alert event - // for RCA: {}", e - // ); - // // Don't fail alert evaluation if RCA collection fails - // } - // } - // log::debug!( - // "[SCHEDULER trace_id {scheduler_trace_id}] Collected {} alert events for RCA - // batch {}", data.len(), - // trace_id - // ); - // } - #[cfg(feature = "enterprise")] let (incident_handled_notification, incident_notify_error) = if alert.creates_incident && o2_enterprise::enterprise::common::config::get_config() @@ -3735,10 +3674,6 @@ async fn handle_alert_triggers( // publish the triggers as stream publish_triggers_usage(trigger_data_stream); - // [ENTERPRISE] Mark alert completed and process batch if this was the last alert - // #[cfg(feature = "enterprise")] - // mark_rca_completion().await; - Ok(()) } diff --git a/src/core/src/alerts/scheduler/worker.rs b/src/core/src/alerts/scheduler/worker.rs index c45f89be13..c919649e72 100644 --- a/src/core/src/alerts/scheduler/worker.rs +++ b/src/core/src/alerts/scheduler/worker.rs @@ -308,21 +308,6 @@ impl SchedulerJobPuller { "[SCHEDULER] [JobPuller-{trace_id}] Pulled {module:?}: {} jobs", module_triggers.len() ); - - // [ENTERPRISE] Register batch for RCA cross-alert correlation - // Only for Alert module - // #[cfg(feature = "enterprise")] - // if matches!(module, TriggerModule::Alert) && !module_triggers.is_empty() { - // log::debug!( - // "[SCHEDULER][JobPuller-{}] Registering RCA batch with {} alerts", - // trace_id, - // module_triggers.len() - // ); - // o2_enterprise::enterprise::ai::rca::register_batch( - // &trace_id, - // module_triggers.len(), - // ); - // } } }