From 90db378ec0d6997bb4dd981ce257ced4790a34b1 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 4 Apr 2022 15:08:28 +0100 Subject: [PATCH] feat: block request rtt metric --- metrics/src/names.rs | 3 ++- network/src/peer.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/metrics/src/names.rs b/metrics/src/names.rs index 0d3694e790..c2147209c7 100644 --- a/metrics/src/names.rs +++ b/metrics/src/names.rs @@ -15,7 +15,7 @@ // along with the snarkOS library. If not, see . pub const GAUGE_NAMES: [&str; 4] = [blocks::HEIGHT, peers::CONNECTED, peers::CANDIDATE, peers::RESTRICTED]; -pub const HISTOGRAM_NAMES: [&str; 2] = [internal_rtt::PING, internal_rtt::PONG]; +pub const HISTOGRAM_NAMES: [&str; 3] = [internal_rtt::PING, internal_rtt::PONG, internal_rtt::BLOCK_REQUEST]; pub mod blocks { pub const HEIGHT: &str = "snarkos_blocks_height_total"; @@ -30,4 +30,5 @@ pub mod peers { pub mod internal_rtt { pub const PING: &str = "snarkos_internal_rtt_ping"; pub const PONG: &str = "snarkos_internal_rtt_pong"; + pub const BLOCK_REQUEST: &str = "snarkos_internal_rtt_block_request"; } diff --git a/network/src/peer.rs b/network/src/peer.rs index 0701498b58..c70246e344 100644 --- a/network/src/peer.rs +++ b/network/src/peer.rs @@ -497,6 +497,10 @@ impl Peer { break; } } + + // Stop the clock on internal RTT. + #[cfg(any(feature = "test", feature = "prometheus"))] + metrics::histogram!(metrics::internal_rtt::BLOCK_REQUEST, rtt_start.elapsed()); }, Message::BlockResponse(block) => { // Perform the deferred non-blocking deserialization of the block. @@ -597,7 +601,6 @@ impl Peer { Err(_) => None, }; - // Stop the clock on internal RTT. #[cfg(any(feature = "test", feature = "prometheus"))] metrics::histogram!(metrics::internal_rtt::PING, rtt_start.elapsed());