Add metrics for subnet queries (#3721)
## Issue Addressed N/A ## Proposed Changes Add metrics for peers discovered in subnet discv5 queries.
This commit is contained in:
parent
713b6a18d4
commit
857ef25d28
@ -834,6 +834,17 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
|||||||
|
|
||||||
// Map each subnet query's min_ttl to the set of ENR's returned for that subnet.
|
// Map each subnet query's min_ttl to the set of ENR's returned for that subnet.
|
||||||
queries.iter().for_each(|query| {
|
queries.iter().for_each(|query| {
|
||||||
|
let query_str = match query.subnet {
|
||||||
|
Subnet::Attestation(_) => "attestation",
|
||||||
|
Subnet::SyncCommittee(_) => "sync_committee",
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(v) = metrics::get_int_counter(
|
||||||
|
&metrics::TOTAL_SUBNET_QUERIES,
|
||||||
|
&[query_str],
|
||||||
|
) {
|
||||||
|
v.inc();
|
||||||
|
}
|
||||||
// A subnet query has completed. Add back to the queue, incrementing retries.
|
// A subnet query has completed. Add back to the queue, incrementing retries.
|
||||||
self.add_subnet_query(query.subnet, query.min_ttl, query.retries + 1);
|
self.add_subnet_query(query.subnet, query.min_ttl, query.retries + 1);
|
||||||
|
|
||||||
@ -845,6 +856,12 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
|
|||||||
.filter(|enr| subnet_predicate(enr))
|
.filter(|enr| subnet_predicate(enr))
|
||||||
.map(|enr| enr.peer_id())
|
.map(|enr| enr.peer_id())
|
||||||
.for_each(|peer_id| {
|
.for_each(|peer_id| {
|
||||||
|
if let Some(v) = metrics::get_int_counter(
|
||||||
|
&metrics::SUBNET_PEERS_FOUND,
|
||||||
|
&[query_str],
|
||||||
|
) {
|
||||||
|
v.inc();
|
||||||
|
}
|
||||||
let other_min_ttl = mapped_results.get_mut(&peer_id);
|
let other_min_ttl = mapped_results.get_mut(&peer_id);
|
||||||
|
|
||||||
// map peer IDs to the min_ttl furthest in the future
|
// map peer IDs to the min_ttl furthest in the future
|
||||||
|
@ -112,6 +112,19 @@ lazy_static! {
|
|||||||
&["client"]
|
&["client"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
pub static ref SUBNET_PEERS_FOUND: Result<IntCounterVec> =
|
||||||
|
try_create_int_counter_vec(
|
||||||
|
"discovery_query_peers_found",
|
||||||
|
"Total number of peers found in attestation subnets and sync subnets",
|
||||||
|
&["type"]
|
||||||
|
);
|
||||||
|
pub static ref TOTAL_SUBNET_QUERIES: Result<IntCounterVec> =
|
||||||
|
try_create_int_counter_vec(
|
||||||
|
"discovery_total_queries",
|
||||||
|
"Total number of discovery subnet queries",
|
||||||
|
&["type"]
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inbound/Outbound peers
|
* Inbound/Outbound peers
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user