diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 501ac9260..5f78a4211 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -2953,6 +2953,7 @@ impl BeaconChain { } metrics::inc_counter(&metrics::FORK_CHOICE_REORG_COUNT); + metrics::inc_counter(&metrics::FORK_CHOICE_REORG_COUNT_INTEROP); warn!( self.log, "Beacon chain re-org"; diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index c8c43201c..7be693a7e 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -269,6 +269,10 @@ lazy_static! { "beacon_fork_choice_reorg_total", "Count of occasions fork choice has switched to a different chain" ); + pub static ref FORK_CHOICE_REORG_COUNT_INTEROP: Result = try_create_int_counter( + "beacon_reorgs_total", + "Count of occasions fork choice has switched to a different chain" + ); pub static ref FORK_CHOICE_TIMES: Result = try_create_histogram("beacon_fork_choice_seconds", "Full runtime of fork choice"); pub static ref FORK_CHOICE_FIND_HEAD_TIMES: Result = @@ -315,6 +319,8 @@ lazy_static! { try_create_histogram("beacon_update_head_seconds", "Time taken to update the canonical head"); pub static ref HEAD_STATE_SLOT: Result = try_create_int_gauge("beacon_head_state_slot", "Slot of the block at the head of the chain"); + pub static ref HEAD_STATE_SLOT_INTEROP: Result = + try_create_int_gauge("beacon_head_slot", "Slot of the block at the head of the chain"); pub static ref HEAD_STATE_ROOT: Result = try_create_int_gauge("beacon_head_state_root", "Root of the block at the head of the chain"); pub static ref HEAD_STATE_LATEST_BLOCK_SLOT: Result = @@ -323,18 +329,26 @@ lazy_static! { try_create_int_gauge("beacon_head_state_current_justified_root", "Current justified root at the head of the chain"); pub static ref HEAD_STATE_CURRENT_JUSTIFIED_EPOCH: Result = try_create_int_gauge("beacon_head_state_current_justified_epoch", "Current justified epoch at the head of the chain"); + pub static ref HEAD_STATE_CURRENT_JUSTIFIED_EPOCH_INTEROP: Result = + try_create_int_gauge("beacon_current_justified_epoch", "Current justified epoch at the head of the chain"); pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_ROOT: Result = try_create_int_gauge("beacon_head_state_previous_justified_root", "Previous justified root at the head of the chain"); pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH: Result = try_create_int_gauge("beacon_head_state_previous_justified_epoch", "Previous justified epoch at the head of the chain"); + pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH_INTEROP: Result = + try_create_int_gauge("beacon_previous_justified_epoch", "Previous justified epoch at the head of the chain"); pub static ref HEAD_STATE_FINALIZED_ROOT: Result = try_create_int_gauge("beacon_head_state_finalized_root", "Finalized root at the head of the chain"); pub static ref HEAD_STATE_FINALIZED_EPOCH: Result = try_create_int_gauge("beacon_head_state_finalized_epoch", "Finalized epoch at the head of the chain"); + pub static ref HEAD_STATE_FINALIZED_EPOCH_INTEROP: Result = + try_create_int_gauge("beacon_finalized_epoch", "Finalized epoch at the head of the chain"); pub static ref HEAD_STATE_TOTAL_VALIDATORS: Result = try_create_int_gauge("beacon_head_state_total_validators_total", "Count of validators at the head of the chain"); pub static ref HEAD_STATE_ACTIVE_VALIDATORS: Result = try_create_int_gauge("beacon_head_state_active_validators_total", "Count of active validators at the head of the chain"); + pub static ref HEAD_STATE_ACTIVE_VALIDATORS_INTEROP: Result = + try_create_int_gauge("beacon_current_active_validators", "Count of active validators at the head of the chain"); pub static ref HEAD_STATE_VALIDATOR_BALANCES: Result = try_create_int_gauge("beacon_head_state_validator_balances_total", "Sum of all validator balances at the head of the chain"); pub static ref HEAD_STATE_SLASHED_VALIDATORS: Result = @@ -343,6 +357,8 @@ lazy_static! { try_create_int_gauge("beacon_head_state_withdrawn_validators_total", "Sum of all validator balances at the head of the chain"); pub static ref HEAD_STATE_ETH1_DEPOSIT_INDEX: Result = try_create_int_gauge("beacon_head_state_eth1_deposit_index", "Eth1 deposit index at the head of the chain"); + pub static ref HEAD_STATE_ETH1_DEPOSITS_INTEROP: Result = + try_create_int_gauge("beacon_processed_deposits_total", "Total Eth1 deposits at the head of the chain"); /* * Operation Pool @@ -876,6 +892,7 @@ pub fn scrape_for_metrics(beacon_chain: &BeaconChain) { /// Scrape the given `state` assuming it's the head state, updating the `DEFAULT_REGISTRY`. fn scrape_head_state(state: &BeaconState, state_root: Hash256) { set_gauge_by_slot(&HEAD_STATE_SLOT, state.slot()); + set_gauge_by_slot(&HEAD_STATE_SLOT_INTEROP, state.slot()); set_gauge_by_hash(&HEAD_STATE_ROOT, state_root); set_gauge_by_slot( &HEAD_STATE_LATEST_BLOCK_SLOT, @@ -889,6 +906,10 @@ fn scrape_head_state(state: &BeaconState, state_root: Hash256) { &HEAD_STATE_CURRENT_JUSTIFIED_EPOCH, state.current_justified_checkpoint().epoch, ); + set_gauge_by_epoch( + &HEAD_STATE_CURRENT_JUSTIFIED_EPOCH_INTEROP, + state.current_justified_checkpoint().epoch, + ); set_gauge_by_hash( &HEAD_STATE_PREVIOUS_JUSTIFIED_ROOT, state.previous_justified_checkpoint().root, @@ -897,6 +918,10 @@ fn scrape_head_state(state: &BeaconState, state_root: Hash256) { &HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH, state.previous_justified_checkpoint().epoch, ); + set_gauge_by_epoch( + &HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH_INTEROP, + state.previous_justified_checkpoint().epoch, + ); set_gauge_by_hash( &HEAD_STATE_FINALIZED_ROOT, state.finalized_checkpoint().root, @@ -905,12 +930,20 @@ fn scrape_head_state(state: &BeaconState, state_root: Hash256) { &HEAD_STATE_FINALIZED_EPOCH, state.finalized_checkpoint().epoch, ); + set_gauge_by_epoch( + &HEAD_STATE_FINALIZED_EPOCH_INTEROP, + state.finalized_checkpoint().epoch, + ); set_gauge_by_usize(&HEAD_STATE_TOTAL_VALIDATORS, state.validators().len()); set_gauge_by_u64( &HEAD_STATE_VALIDATOR_BALANCES, state.balances().iter().sum(), ); set_gauge_by_u64(&HEAD_STATE_ETH1_DEPOSIT_INDEX, state.eth1_deposit_index()); + set_gauge_by_u64( + &HEAD_STATE_ETH1_DEPOSITS_INTEROP, + state.eth1_data().deposit_count, + ); set_gauge_by_usize(&HEAD_STATE_TOTAL_VALIDATORS, state.validators().len()); set_gauge_by_u64( &HEAD_STATE_VALIDATOR_BALANCES, @@ -936,6 +969,7 @@ fn scrape_head_state(state: &BeaconState, state_root: Hash256) { } set_gauge_by_usize(&HEAD_STATE_ACTIVE_VALIDATORS, num_active); + set_gauge_by_usize(&HEAD_STATE_ACTIVE_VALIDATORS_INTEROP, num_active); set_gauge_by_usize(&HEAD_STATE_SLASHED_VALIDATORS, num_slashed); set_gauge_by_usize(&HEAD_STATE_WITHDRAWN_VALIDATORS, num_withdrawn); } diff --git a/beacon_node/eth2_libp2p/src/metrics.rs b/beacon_node/eth2_libp2p/src/metrics.rs index d27cdd3fb..4767f287f 100644 --- a/beacon_node/eth2_libp2p/src/metrics.rs +++ b/beacon_node/eth2_libp2p/src/metrics.rs @@ -9,6 +9,8 @@ lazy_static! { "libp2p_peer_connected_peers_total", "Count of libp2p peers currently connected" ); + pub static ref PEERS_CONNECTED_INTEROP: Result = + try_create_int_gauge("libp2p_peers", "Count of libp2p peers currently connected"); pub static ref PEER_CONNECT_EVENT_COUNT: Result = try_create_int_counter( "libp2p_peer_connect_event_total", "Count of libp2p peer connect events (not the current number of connected peers)" diff --git a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs index 74923b3c7..9aa041000 100644 --- a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs +++ b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs @@ -401,12 +401,12 @@ impl PeerManager { } } + let connected_peers = self.network_globals.connected_peers() as i64; + // increment prometheus metrics metrics::inc_counter(&metrics::PEER_CONNECT_EVENT_COUNT); - metrics::set_gauge( - &metrics::PEERS_CONNECTED, - self.network_globals.connected_peers() as i64, - ); + metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); + metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); } pub fn inject_connection_closed( @@ -456,12 +456,12 @@ impl PeerManager { // reference so that peer manager can track this peer. self.inject_disconnect(&peer_id); + let connected_peers = self.network_globals.connected_peers() as i64; + // Update the prometheus metrics metrics::inc_counter(&metrics::PEER_DISCONNECT_EVENT_COUNT); - metrics::set_gauge( - &metrics::PEERS_CONNECTED, - self.network_globals.connected_peers() as i64, - ); + metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); + metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); } } @@ -866,12 +866,12 @@ impl PeerManager { // start a ping and status timer for the peer self.status_peers.insert(*peer_id); + let connected_peers = self.network_globals.connected_peers() as i64; + // increment prometheus metrics metrics::inc_counter(&metrics::PEER_CONNECT_EVENT_COUNT); - metrics::set_gauge( - &metrics::PEERS_CONNECTED, - self.network_globals.connected_peers() as i64, - ); + metrics::set_gauge(&metrics::PEERS_CONNECTED, connected_peers); + metrics::set_gauge(&metrics::PEERS_CONNECTED_INTEROP, connected_peers); // Increment the PEERS_PER_CLIENT metric if let Some(kind) = self