mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +00:00
Add more prometheus metrics to network::Protocol. (#5145)
This commit is contained in:
@@ -1202,6 +1202,27 @@ impl<B: BlockT> ChainSync<B> {
|
||||
fn is_already_downloading(&self, hash: &B::Hash) -> bool {
|
||||
self.peers.iter().any(|(_, p)| p.state == PeerSyncState::DownloadingStale(*hash))
|
||||
}
|
||||
|
||||
/// Return some key metrics.
|
||||
pub(crate) fn metrics(&self) -> Metrics {
|
||||
use std::convert::TryInto;
|
||||
Metrics {
|
||||
queued_blocks: self.queue_blocks.len().try_into().unwrap_or(std::u32::MAX),
|
||||
fork_targets: self.fork_targets.len().try_into().unwrap_or(std::u32::MAX),
|
||||
finality_proofs: self.extra_finality_proofs.metrics(),
|
||||
justifications: self.extra_justifications.metrics(),
|
||||
_priv: ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Metrics {
|
||||
pub(crate) queued_blocks: u32,
|
||||
pub(crate) fork_targets: u32,
|
||||
pub(crate) finality_proofs: extra_requests::Metrics,
|
||||
pub(crate) justifications: extra_requests::Metrics,
|
||||
_priv: ()
|
||||
}
|
||||
|
||||
/// Request the ancestry for a block. Sends a request for header and justification for the given
|
||||
|
||||
Reference in New Issue
Block a user