From 8cb92e35f113688c0dc922b26ae24c9be6837ca4 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 11 Sep 2023 13:17:39 +0200 Subject: [PATCH] feat: add metrics for inflight get pooled tx requests (#4547) --- crates/net/network/src/metrics.rs | 2 ++ crates/net/network/src/transactions.rs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/net/network/src/metrics.rs b/crates/net/network/src/metrics.rs index 7245624ca..a25c84e88 100644 --- a/crates/net/network/src/metrics.rs +++ b/crates/net/network/src/metrics.rs @@ -67,6 +67,8 @@ pub struct TransactionsManagerMetrics { pub(crate) messages_with_already_seen_transactions: Counter, /// Number of transactions about to be imported into the pool. pub(crate) pending_pool_imports: Gauge, + /// Currently active outgoing GetPooledTransactions requests. + pub(crate) inflight_transaction_requests: Gauge, /// How often we failed to send a request to the peer because the channel was full. pub(crate) egress_peer_channel_full: Counter, } diff --git a/crates/net/network/src/transactions.rs b/crates/net/network/src/transactions.rs index 17318aa67..130fc65aa 100644 --- a/crates/net/network/src/transactions.rs +++ b/crates/net/network/src/transactions.rs @@ -174,10 +174,16 @@ where TransactionsHandle { manager_tx: self.command_tx.clone() } } + #[inline] fn update_import_metrics(&self) { self.metrics.pending_pool_imports.set(self.pool_imports.len() as f64); } + #[inline] + fn update_request_metrics(&self) { + self.metrics.inflight_transaction_requests.set(self.inflight_requests.len() as f64); + } + /// Request handler for an incoming request for transactions fn on_get_pooled_transactions( &mut self, @@ -591,6 +597,8 @@ where this.on_network_tx_event(event); } + this.update_request_metrics(); + // Advance all requests. while let Poll::Ready(Some(GetPooledTxResponse { peer_id, result })) = this.inflight_requests.poll_next_unpin(cx) @@ -609,6 +617,7 @@ where } } + this.update_request_metrics(); this.update_import_metrics(); // Advance all imports