diff --git a/src/common/src/telemetry/report.rs b/src/common/src/telemetry/report.rs index f4737038863b0..f056ddfcb6dee 100644 --- a/src/common/src/telemetry/report.rs +++ b/src/common/src/telemetry/report.rs @@ -101,17 +101,25 @@ where }); let (tx, mut event_rx) = tokio::sync::mpsc::unbounded_channel::(); + + let mut enable_event_report = true; TELEMETRY_EVENT_REPORT_TX.set(tx).unwrap_or_else(|_| { tracing::warn!( "Telemetry failed to set event reporting tx, event reporting will be disabled" ); + // possible failure: + // When running in standalone mode, the static TELEMETRY_EVENT_REPORT_TX is shared + // and can be set by meta/compute nodes. + // In such case, the one first set the static will do the event reporting and others' + // event report is disabled. + enable_event_report = false; }); let mut event_stash = Vec::new(); loop { tokio::select! { _ = interval.tick() => {}, - event = event_rx.recv() => { + event = event_rx.recv(), if enable_event_report => { debug_assert!(event.is_some()); event_stash.push(event.unwrap()); if event_stash.len() >= TELEMETRY_EVENT_REPORT_STASH_SIZE { @@ -119,7 +127,7 @@ where } continue; } - _ = event_interval.tick() => { + _ = event_interval.tick(), if enable_event_report => { do_telemetry_event_report(&mut event_stash).await; continue; }, diff --git a/src/common/telemetry_event/src/lib.rs b/src/common/telemetry_event/src/lib.rs index 18874f4818627..e12a3601840c7 100644 --- a/src/common/telemetry_event/src/lib.rs +++ b/src/common/telemetry_event/src/lib.rs @@ -46,6 +46,10 @@ pub fn get_telemetry_risingwave_cloud_uuid() -> Option { } pub async fn do_telemetry_event_report(event_stash: &mut Vec) { + if event_stash.is_empty() { + return; + } + const TELEMETRY_EVENT_REPORT_TYPE: &str = "events"; // the batch report url let url = (TELEMETRY_REPORT_URL.to_owned() + "/" + TELEMETRY_EVENT_REPORT_TYPE).to_owned(); let batch_message = PbBatchEventMessage {