Add basic metrics to libp2p
This commit is contained in:
parent
0b4a8893a4
commit
cac0e5c832
@ -26,3 +26,5 @@ smallvec = "0.6.10"
|
|||||||
fnv = "1.0.6"
|
fnv = "1.0.6"
|
||||||
unsigned-varint = "0.2.2"
|
unsigned-varint = "0.2.2"
|
||||||
bytes = "0.4.12"
|
bytes = "0.4.12"
|
||||||
|
lazy_static = "1.3.0"
|
||||||
|
lighthouse_metrics = { path = "../../eth2/utils/lighthouse_metrics" }
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::metrics;
|
||||||
use crate::{error, NetworkConfig};
|
use crate::{error, NetworkConfig};
|
||||||
/// This manages the discovery and management of peers.
|
/// This manages the discovery and management of peers.
|
||||||
///
|
///
|
||||||
@ -158,10 +159,12 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn inject_connected(&mut self, peer_id: PeerId, _endpoint: ConnectedPoint) {
|
fn inject_connected(&mut self, peer_id: PeerId, _endpoint: ConnectedPoint) {
|
||||||
|
metrics::inc_counter(&metrics::PEER_CONNECT_COUNT);
|
||||||
self.connected_peers.insert(peer_id);
|
self.connected_peers.insert(peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inject_disconnected(&mut self, peer_id: &PeerId, _endpoint: ConnectedPoint) {
|
fn inject_disconnected(&mut self, peer_id: &PeerId, _endpoint: ConnectedPoint) {
|
||||||
|
metrics::inc_counter(&metrics::PEER_DISCONNECT_COUNT);
|
||||||
self.connected_peers.remove(peer_id);
|
self.connected_peers.remove(peer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +220,7 @@ where
|
|||||||
}
|
}
|
||||||
Discv5Event::SocketUpdated(socket) => {
|
Discv5Event::SocketUpdated(socket) => {
|
||||||
info!(self.log, "Address updated"; "IP" => format!("{}",socket.ip()));
|
info!(self.log, "Address updated"; "IP" => format!("{}",socket.ip()));
|
||||||
|
metrics::inc_counter(&metrics::ADDRESS_UPDATE_COUNT);
|
||||||
let mut address = Multiaddr::from(socket.ip());
|
let mut address = Multiaddr::from(socket.ip());
|
||||||
address.push(Protocol::Tcp(self.tcp_port));
|
address.push(Protocol::Tcp(self.tcp_port));
|
||||||
let enr = self.discovery.local_enr();
|
let enr = self.discovery.local_enr();
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
/// all required libp2p functionality.
|
/// all required libp2p functionality.
|
||||||
///
|
///
|
||||||
/// This crate builds and manages the libp2p services required by the beacon node.
|
/// This crate builds and manages the libp2p services required by the beacon node.
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
|
||||||
pub mod behaviour;
|
pub mod behaviour;
|
||||||
mod config;
|
mod config;
|
||||||
mod discovery;
|
mod discovery;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
|
mod metrics;
|
||||||
pub mod rpc;
|
pub mod rpc;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
||||||
|
16
beacon_node/eth2-libp2p/src/metrics.rs
Normal file
16
beacon_node/eth2-libp2p/src/metrics.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pub use lighthouse_metrics::*;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref ADDRESS_UPDATE_COUNT: Result<IntCounter> = try_create_int_counter(
|
||||||
|
"libp2p_address_update_count",
|
||||||
|
"Count of libp2p socked updated events (when our view of our IP address has changed)"
|
||||||
|
);
|
||||||
|
pub static ref PEER_CONNECT_COUNT: Result<IntCounter> = try_create_int_counter(
|
||||||
|
"libp2p_peer_connect_count",
|
||||||
|
"Count of libp2p peer connect events (not the current number of connected peers)"
|
||||||
|
);
|
||||||
|
pub static ref PEER_DISCONNECT_COUNT: Result<IntCounter> = try_create_int_counter(
|
||||||
|
"libp2p_peer_disconnect_count",
|
||||||
|
"Count of libp2p peer disconnect events"
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user