Skip to content

Commit d084559

Browse files
committed
Adding notification metrics
1 parent 786ff37 commit d084559

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

linera-rpc/src/grpc/server.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ mod metrics {
102102
&[],
103103
)
104104
});
105+
106+
pub static NOTIFICATIONS_SKIPPED_RECEIVER_LAG: LazyLock<IntCounterVec> = LazyLock::new(|| {
107+
register_int_counter_vec(
108+
"notifications_skipped_receiver_lag",
109+
"Number of notifications skipped because receiver lagged behind sender",
110+
&[],
111+
)
112+
});
113+
114+
pub static NOTIFICATIONS_DROPPED_NO_RECEIVER: LazyLock<IntCounterVec> = LazyLock::new(|| {
115+
register_int_counter_vec(
116+
"notifications_dropped_no_receiver",
117+
"Number of notifications dropped because no receiver was available",
118+
&[],
119+
)
120+
});
105121
}
106122

107123
#[derive(Clone)]
@@ -320,6 +336,10 @@ where
320336
nickname,
321337
skipped_count, "notification receiver lagged, messages were skipped"
322338
);
339+
#[cfg(with_metrics)]
340+
metrics::NOTIFICATIONS_SKIPPED_RECEIVER_LAG
341+
.with_label_values(&[])
342+
.inc_by(skipped_count);
323343
continue;
324344
}
325345
Err(RecvError::Closed) => {
@@ -395,7 +415,10 @@ where
395415
trace!("Scheduling notification query");
396416
if let Err(error) = notification_sender.send(notification) {
397417
error!(%error, "dropping notification");
398-
break;
418+
#[cfg(with_metrics)]
419+
metrics::NOTIFICATIONS_DROPPED_NO_RECEIVER
420+
.with_label_values(&[])
421+
.inc();
399422
}
400423
}
401424
}

0 commit comments

Comments
 (0)