Skip to content

Commit

Permalink
feat: block request rtt metric
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaslong committed May 9, 2022
1 parent fe2833f commit 90db378
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion metrics/src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with the snarkOS library. If not, see <https://www.gnu.org/licenses/>.

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";
Expand All @@ -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";
}
5 changes: 4 additions & 1 deletion network/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ impl<N: Network, E: Environment> Peer<N, E> {
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.
Expand Down Expand Up @@ -597,7 +601,6 @@ impl<N: Network, E: Environment> Peer<N, E> {
Err(_) => None,
};


// Stop the clock on internal RTT.
#[cfg(any(feature = "test", feature = "prometheus"))]
metrics::histogram!(metrics::internal_rtt::PING, rtt_start.elapsed());
Expand Down

0 comments on commit 90db378

Please sign in to comment.