From 6e7d5c6a7cce17c47e165d43c12825039fcdf802 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 28 Jun 2020 10:47:03 +1000 Subject: [PATCH] Add metrics for validator subscriptions (#1302) --- beacon_node/network/src/attestation_service/mod.rs | 3 +++ beacon_node/network/src/metrics.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/beacon_node/network/src/attestation_service/mod.rs b/beacon_node/network/src/attestation_service/mod.rs index 5ee201ff98..dfaf471987 100644 --- a/beacon_node/network/src/attestation_service/mod.rs +++ b/beacon_node/network/src/attestation_service/mod.rs @@ -2,6 +2,7 @@ //! given time. It schedules subscriptions to shard subnets, requests peer discoveries and //! determines whether attestations should be aggregated and/or passed to the beacon node. +use crate::metrics; use beacon_chain::{BeaconChain, BeaconChainTypes}; use eth2_libp2p::{types::GossipKind, NetworkGlobals}; use futures::prelude::*; @@ -191,6 +192,7 @@ impl AttestationService { subscriptions: Vec, ) -> Result<(), String> { for subscription in subscriptions { + metrics::inc_counter(&metrics::SUBNET_SUBSCRIPTION_REQUESTS); //NOTE: We assume all subscriptions have been verified before reaching this service // Registers the validator with the attestation service. @@ -237,6 +239,7 @@ impl AttestationService { // TODO: Implement if subscription.is_aggregator { + metrics::inc_counter(&metrics::SUBNET_SUBSCRIPTION_AGGREGATOR_REQUESTS); // set the subscription timer to subscribe to the next subnet if required if let Err(e) = self.subscribe_to_subnet(exact_subnet.clone()) { warn!(self.log, diff --git a/beacon_node/network/src/metrics.rs b/beacon_node/network/src/metrics.rs index bc45546623..e7b4b53c09 100644 --- a/beacon_node/network/src/metrics.rs +++ b/beacon_node/network/src/metrics.rs @@ -36,4 +36,16 @@ lazy_static! { "network_gossip_aggregated_attestations_tx_total", "Count of gossip aggregated attestations transmitted" ); + + /* + * Attestation subnet subscriptions + */ + pub static ref SUBNET_SUBSCRIPTION_REQUESTS: Result = try_create_int_counter( + "network_subnet_subscriptions_total", + "Count of validator subscription requests." + ); + pub static ref SUBNET_SUBSCRIPTION_AGGREGATOR_REQUESTS: Result = try_create_int_counter( + "network_subnet_subscriptions_aggregator_total", + "Count of validator subscription requests where the subscriber is an aggregator." + ); }