Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
adds metrics for number of nodes vs number of pubkeys (backport #20512)…
Browse files Browse the repository at this point in the history
… (#20523)

* adds metrics for number of nodes vs number of pubkeys (#20512)

(cherry picked from commit 0da661d)

# Conflicts:
#	gossip/src/cluster_info_metrics.rs

* removes backport merge conflicts

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
  • Loading branch information
mergify[bot] and behzadnouri authored Oct 8, 2021
1 parent 8f07b46 commit 9ff9234
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion gossip/src/cluster_info_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ pub(crate) fn submit_gossip_stats(
gossip: &RwLock<CrdsGossip>,
stakes: &HashMap<Pubkey, u64>,
) {
let (table_size, num_nodes, purged_values_size, failed_inserts_size) = {
let (table_size, num_nodes, num_pubkeys, purged_values_size, failed_inserts_size) = {
let gossip = gossip.read().unwrap();
(
gossip.crds.len(),
gossip.crds.num_nodes(),
gossip.crds.num_pubkeys(),
gossip.crds.num_purged(),
gossip.pull.failed_inserts.len(),
)
Expand All @@ -192,6 +193,7 @@ pub(crate) fn submit_gossip_stats(
("failed_inserts_size", failed_inserts_size as i64, i64),
("num_nodes", num_nodes as i64, i64),
("num_nodes_staked", num_nodes_staked as i64, i64),
("num_pubkeys", num_pubkeys, i64),
);
datapoint_info!(
"cluster_info_stats2",
Expand Down
7 changes: 6 additions & 1 deletion gossip/src/crds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,13 @@ impl Crds {
.map(move |i| self.table.index(*i))
}

/// Returns number of known pubkeys (network size).
/// Returns number of known contact-infos (network size).
pub(crate) fn num_nodes(&self) -> usize {
self.nodes.len()
}

/// Returns number of unique pubkeys.
pub(crate) fn num_pubkeys(&self) -> usize {
self.records.len()
}

Expand Down

0 comments on commit 9ff9234

Please sign in to comment.