Fold noisy metric into struct of metrics that is reported every 10s (#33635)
This commit is contained in:
parent
a22678312e
commit
73a9a14731
|
@ -18,7 +18,7 @@ use {
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
str,
|
str,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicUsize, Ordering},
|
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
},
|
},
|
||||||
thread::{self, Builder, JoinHandle},
|
thread::{self, Builder, JoinHandle},
|
||||||
|
@ -132,6 +132,7 @@ struct SentNotificationStats {
|
||||||
num_root: AtomicUsize,
|
num_root: AtomicUsize,
|
||||||
num_vote: AtomicUsize,
|
num_vote: AtomicUsize,
|
||||||
num_block: AtomicUsize,
|
num_block: AtomicUsize,
|
||||||
|
total_creation_to_queue_time_us: AtomicU64,
|
||||||
last_report: AtomicInterval,
|
last_report: AtomicInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +186,12 @@ impl SentNotificationStats {
|
||||||
self.num_block.swap(0, Ordering::Relaxed) as i64,
|
self.num_block.swap(0, Ordering::Relaxed) as i64,
|
||||||
i64
|
i64
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"total_creation_to_queue_time_us",
|
||||||
|
self.total_creation_to_queue_time_us
|
||||||
|
.swap(0, Ordering::Relaxed) as i64,
|
||||||
|
i64
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,6 +204,7 @@ struct BroadcastHandler {
|
||||||
|
|
||||||
fn increment_sent_notification_stats(
|
fn increment_sent_notification_stats(
|
||||||
params: &SubscriptionParams,
|
params: &SubscriptionParams,
|
||||||
|
notification: &RpcNotification,
|
||||||
stats: &Arc<SentNotificationStats>,
|
stats: &Arc<SentNotificationStats>,
|
||||||
) {
|
) {
|
||||||
match params {
|
match params {
|
||||||
|
@ -228,6 +236,11 @@ fn increment_sent_notification_stats(
|
||||||
stats.num_block.fetch_add(1, Ordering::Relaxed);
|
stats.num_block.fetch_add(1, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stats.total_creation_to_queue_time_us.fetch_add(
|
||||||
|
notification.created_at.elapsed().as_micros() as u64,
|
||||||
|
Ordering::Relaxed,
|
||||||
|
);
|
||||||
|
|
||||||
stats.maybe_report();
|
stats.maybe_report();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,17 +258,10 @@ impl BroadcastHandler {
|
||||||
.current_subscriptions
|
.current_subscriptions
|
||||||
.entry(notification.subscription_id)
|
.entry(notification.subscription_id)
|
||||||
{
|
{
|
||||||
increment_sent_notification_stats(entry.get().params(), &self.sent_stats);
|
increment_sent_notification_stats(
|
||||||
|
entry.get().params(),
|
||||||
let time_since_created = notification.created_at.elapsed();
|
¬ification,
|
||||||
|
&self.sent_stats,
|
||||||
datapoint_info!(
|
|
||||||
"pubsub_notifications",
|
|
||||||
(
|
|
||||||
"created_to_queue_time_us",
|
|
||||||
time_since_created.as_micros() as i64,
|
|
||||||
i64
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if notification.is_final {
|
if notification.is_final {
|
||||||
|
|
Loading…
Reference in New Issue