Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: telemetry init channel unsuccessful leads to panic #20160

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/common/src/telemetry/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,29 @@ where
});

let (tx, mut event_rx) = tokio::sync::mpsc::unbounded_channel::<PbEventMessage>();

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() => {
if !enable_event_report {
tabVersion marked this conversation as resolved.
Show resolved Hide resolved
// if have error creating the channel, will get None message from the channel
continue;
}
debug_assert!(event.is_some());
event_stash.push(event.unwrap());
if event_stash.len() >= TELEMETRY_EVENT_REPORT_STASH_SIZE {
Expand All @@ -120,6 +132,9 @@ where
continue;
}
_ = event_interval.tick() => {
if !enable_event_report {
tabVersion marked this conversation as resolved.
Show resolved Hide resolved
continue;
}
do_telemetry_event_report(&mut event_stash).await;
continue;
},
Expand Down
4 changes: 4 additions & 0 deletions src/common/telemetry_event/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ pub fn get_telemetry_risingwave_cloud_uuid() -> Option<String> {
}

pub async fn do_telemetry_event_report(event_stash: &mut Vec<PbEventMessage>) {
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 {
Expand Down
Loading