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

Fold noisy metric into struct of metrics that is reported every 10s #33635

Merged
merged 1 commit into from
Oct 10, 2023
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
Fold noisy metric into struct of metrics that is reported every 10s
Steven Czabaniuk committed Oct 10, 2023
commit 1f4ddccacd6b53eba9a06dd79a1d2797118a377b
30 changes: 18 additions & 12 deletions rpc/src/rpc_pubsub_service.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ use {
net::SocketAddr,
str,
sync::{
atomic::{AtomicUsize, Ordering},
atomic::{AtomicU64, AtomicUsize, Ordering},
Arc,
},
thread::{self, Builder, JoinHandle},
@@ -132,6 +132,7 @@ struct SentNotificationStats {
num_root: AtomicUsize,
num_vote: AtomicUsize,
num_block: AtomicUsize,
total_creation_to_queue_time_us: AtomicU64,
last_report: AtomicInterval,
}

@@ -185,6 +186,12 @@ impl SentNotificationStats {
self.num_block.swap(0, Ordering::Relaxed) as 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(
params: &SubscriptionParams,
notification: &RpcNotification,
stats: &Arc<SentNotificationStats>,
) {
match params {
@@ -228,6 +236,11 @@ fn increment_sent_notification_stats(
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();
}

@@ -245,17 +258,10 @@ impl BroadcastHandler {
.current_subscriptions
.entry(notification.subscription_id)
{
increment_sent_notification_stats(entry.get().params(), &self.sent_stats);

let time_since_created = notification.created_at.elapsed();

datapoint_info!(
"pubsub_notifications",
(
"created_to_queue_time_us",
time_since_created.as_micros() as i64,
i64
),
increment_sent_notification_stats(
entry.get().params(),
&notification,
&self.sent_stats,
);

if notification.is_final {