diff --git a/linera-rpc/src/grpc/server.rs b/linera-rpc/src/grpc/server.rs index 7f96428bffb0..6a75b42d2bb7 100644 --- a/linera-rpc/src/grpc/server.rs +++ b/linera-rpc/src/grpc/server.rs @@ -102,6 +102,22 @@ mod metrics { &[], ) }); + + pub static NOTIFICATIONS_SKIPPED_RECEIVER_LAG: LazyLock = LazyLock::new(|| { + register_int_counter_vec( + "notifications_skipped_receiver_lag", + "Number of notifications skipped because receiver lagged behind sender", + &[], + ) + }); + + pub static NOTIFICATIONS_DROPPED_NO_RECEIVER: LazyLock = LazyLock::new(|| { + register_int_counter_vec( + "notifications_dropped_no_receiver", + "Number of notifications dropped because no receiver was available", + &[], + ) + }); } #[derive(Clone)] @@ -320,6 +336,10 @@ where nickname, skipped_count, "notification receiver lagged, messages were skipped" ); + #[cfg(with_metrics)] + metrics::NOTIFICATIONS_SKIPPED_RECEIVER_LAG + .with_label_values(&[]) + .inc_by(skipped_count); continue; } Err(RecvError::Closed) => { @@ -395,7 +415,10 @@ where trace!("Scheduling notification query"); if let Err(error) = notification_sender.send(notification) { error!(%error, "dropping notification"); - break; + #[cfg(with_metrics)] + metrics::NOTIFICATIONS_DROPPED_NO_RECEIVER + .with_label_values(&[]) + .inc(); } } }