Skip to content
Merged
Changes from all 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
12 changes: 7 additions & 5 deletions metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use {
crate::{counter::CounterPoint, datapoint::DataPoint},
crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender},
crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError},
gethostname::gethostname,
log::*,
solana_cluster_type::ClusterType,
Expand Down Expand Up @@ -313,7 +313,7 @@ impl MetricsAgent {
};

loop {
match receiver.recv_timeout(write_frequency / 2) {
match receiver.try_recv() {
Ok(cmd) => match cmd {
MetricsCommand::Flush(barrier) => {
debug!("metrics_thread: flush");
Expand All @@ -334,12 +334,14 @@ impl MetricsAgent {
}
}
},
Err(RecvTimeoutError::Timeout) => (),
Err(RecvTimeoutError::Disconnected) => {
Err(TryRecvError::Empty) => {
std::thread::sleep(Duration::from_millis(5));
}
Err(TryRecvError::Disconnected) => {
debug!("run: sender disconnected");
break;
}
}
};

let now = Instant::now();
if now.duration_since(last_write_time) >= write_frequency {
Expand Down
Loading