Quic client stats (#24195) (#24305)

* Add metrics to connection-cache to measure cache hits and misses

* Add congestion stats

* Add more client stats

* Review comments

Co-authored-by: Ryan Leung <ryan.leung@solana.com>

Co-authored-by: sakridge <sakridge@gmail.com>
Co-authored-by: Ryan Leung <ryan.leung@solana.com>
This commit is contained in:
mergify[bot]
2022-04-14 16:42:20 -04:00
committed by GitHub
parent 304cd65ecb
commit 58ef6b31f9
8 changed files with 345 additions and 63 deletions

View File

@ -3,7 +3,28 @@ pub mod counter;
pub mod datapoint;
mod metrics;
pub use crate::metrics::{flush, query, set_host_id, set_panic_hook, submit};
use std::sync::Arc;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
// To track an external counter which cannot be reset and is always increasing
#[derive(Default)]
pub struct MovingStat {
value: AtomicU64,
}
impl MovingStat {
pub fn update_stat(&self, old_value: &MovingStat, new_value: u64) {
let old = old_value.value.swap(new_value, Ordering::Acquire);
self.value
.fetch_add(new_value.saturating_sub(old), Ordering::Release);
}
pub fn load_and_reset(&self) -> u64 {
self.value.swap(0, Ordering::Acquire)
}
}
/// A helper that sends the count of created tokens as a datapoint.
#[allow(clippy::redundant_allocation)]