Skip to content

Commit

Permalink
beefy/metrics: Add number of live peers available for requests (#5859)
Browse files Browse the repository at this point in the history
This PR adds a new beefy metric to monitor the number of live beefy
peers.

Part of investigation of litep2p request failures:
#4985

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv authored Oct 6, 2024
1 parent 6a29a61 commit c733c52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions prdoc/pr_5859.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Add number of live peers available for requests

doc:
- audience: [Node Operator, Node Dev]
description: |
This PR adds a new metric for the number of live peers available for beefy requests.
The metric is exposed under the name `substrate_beefy_on_demand_live_peers`.

crates:
- name: sc-consensus-beefy
bump: minor
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{
request_response::{Error, JustificationRequest, BEEFY_SYNC_LOG_TARGET},
},
justification::{decode_and_verify_finality_proof, BeefyVersionedFinalityProof},
metric_inc,
metric_inc, metric_set,
metrics::{register_metrics, OnDemandOutgoingRequestsMetrics},
KnownPeers,
};
Expand Down Expand Up @@ -242,6 +242,8 @@ impl<B: Block, AuthorityId: AuthorityIdBound> OnDemandJustificationsEngine<B, Au
// meaning we're done with current state. Move the engine to `State::Idle`.
self.state = State::Idle;

metric_set!(self.metrics, beefy_on_demand_live_peers, self.live_peers.lock().len() as u64);

let block = req_info.block;
match self.process_response(&peer, &req_info, resp) {
Err(err) => {
Expand Down
9 changes: 9 additions & 0 deletions substrate/client/consensus/beefy/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ pub struct OnDemandOutgoingRequestsMetrics {
pub beefy_on_demand_justification_invalid_proof: Counter<U64>,
/// Number of on-demand justification good proof
pub beefy_on_demand_justification_good_proof: Counter<U64>,
/// Number of live beefy peers available for requests.
pub beefy_on_demand_live_peers: Gauge<U64>,
}

impl PrometheusRegister for OnDemandOutgoingRequestsMetrics {
Expand Down Expand Up @@ -277,6 +279,13 @@ impl PrometheusRegister for OnDemandOutgoingRequestsMetrics {
)?,
registry,
)?,
beefy_on_demand_live_peers: register(
Gauge::new(
"substrate_beefy_on_demand_live_peers",
"Number of live beefy peers available for requests.",
)?,
registry,
)?,
})
}
}
Expand Down

0 comments on commit c733c52

Please sign in to comment.