mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Add an authority_discovery_known_authorities_count metric (#6614)
This commit is contained in:
@@ -68,6 +68,11 @@ where
|
||||
self.cache.insert(id, addresses);
|
||||
}
|
||||
|
||||
/// Returns the number of authority IDs in the cache.
|
||||
pub fn num_ids(&self) -> usize {
|
||||
self.cache.len()
|
||||
}
|
||||
|
||||
// Each node should connect to a subset of all authorities. In order to prevent hot spots, this
|
||||
// selection is based on randomness. Selecting randomly each time we alter the address cache
|
||||
// would result in connection churn. To reduce this churn a node generates a seed on startup and
|
||||
|
||||
@@ -481,6 +481,11 @@ where
|
||||
|
||||
if !remote_addresses.is_empty() {
|
||||
self.addr_cache.insert(authority_id.clone(), remote_addresses);
|
||||
if let Some(metrics) = &self.metrics {
|
||||
metrics.known_authorities_count.set(
|
||||
self.addr_cache.num_ids().try_into().unwrap_or(std::u64::MAX)
|
||||
);
|
||||
}
|
||||
self.update_peer_set_priority_group()?;
|
||||
}
|
||||
|
||||
@@ -651,6 +656,7 @@ pub(crate) struct Metrics {
|
||||
request: Counter<U64>,
|
||||
dht_event_received: CounterVec<U64>,
|
||||
handle_value_found_event_failure: Counter<U64>,
|
||||
known_authorities_count: Gauge<U64>,
|
||||
priority_group_size: Gauge<U64>,
|
||||
}
|
||||
|
||||
@@ -697,6 +703,13 @@ impl Metrics {
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
known_authorities_count: register(
|
||||
Gauge::new(
|
||||
"authority_discovery_known_authorities_count",
|
||||
"Number of authorities known by authority discovery."
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
priority_group_size: register(
|
||||
Gauge::new(
|
||||
"authority_discovery_priority_group_size",
|
||||
|
||||
Reference in New Issue
Block a user