#3667 Add Dial Success Metric (#3729)

This commit is contained in:
Max Wolff
2023-07-12 15:51:43 -07:00
committed by GitHub
parent 9e330f111d
commit f6646aa452
2 changed files with 21 additions and 0 deletions

View File

@ -45,6 +45,14 @@ pub struct NetworkMetrics {
pub(crate) total_dropped_eth_requests_at_full_capacity: Counter,
}
/// Metrics for SessionManager
#[derive(Metrics)]
#[metrics(scope = "network")]
pub struct SesssionManagerMetrics {
/// Number of dials that resulted in a peer being added to the peerset
pub(crate) total_dial_successes: Counter,
}
/// Metrics for the TransactionsManager
#[derive(Metrics)]
#[metrics(scope = "network")]

View File

@ -1,6 +1,7 @@
//! Support for handling peer sessions.
use crate::{
message::PeerMessage,
metrics::SesssionManagerMetrics,
session::{
active::ActiveSession,
config::SessionCounter,
@ -101,6 +102,8 @@ pub(crate) struct SessionManager {
active_session_rx: ReceiverStream<ActiveSessionMessage>,
/// Used to measure inbound & outbound bandwidth across all managed streams
bandwidth_meter: BandwidthMeter,
/// Metrics for the session manager.
metrics: SesssionManagerMetrics,
}
// === impl SessionManager ===
@ -137,6 +140,7 @@ impl SessionManager {
active_session_tx: MeteredSender::new(active_session_tx, "network_active_session"),
active_session_rx: ReceiverStream::new(active_session_rx),
bandwidth_meter,
metrics: Default::default(),
}
}
@ -473,6 +477,10 @@ impl SessionManager {
self.active_sessions.insert(peer_id, handle);
self.counter.inc_active(&direction);
if direction.is_outgoing() {
self.metrics.total_dial_successes.increment(1);
}
Poll::Ready(SessionEvent::SessionEstablished {
peer_id,
remote_addr,
@ -695,6 +703,11 @@ impl Direction {
pub(crate) fn is_incoming(&self) -> bool {
matches!(self, Direction::Incoming)
}
/// Returns `true` if this an outgoing connection.
pub(crate) fn is_outgoing(&self) -> bool {
matches!(self, Direction::Outgoing(_))
}
}
impl std::fmt::Display for Direction {