From 3390671cb6b8dfed76c522026c50ac609bd66e40 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 22 Jun 2023 20:53:47 +0200 Subject: [PATCH] chore: add pending imports metrics (#3344) --- crates/net/network/src/metrics.rs | 2 ++ crates/net/network/src/transactions.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/crates/net/network/src/metrics.rs b/crates/net/network/src/metrics.rs index 273e77e734..bea6d8cd43 100644 --- a/crates/net/network/src/metrics.rs +++ b/crates/net/network/src/metrics.rs @@ -54,6 +54,8 @@ pub struct TransactionsManagerMetrics { pub(crate) messages_with_already_seen_hashes: Counter, /// Total number of messages with already seen full transactions pub(crate) messages_with_already_seen_transactions: Counter, + /// Number of transactions about to be imported into the pool. + pub(crate) pending_pool_imports: Gauge, } /// Metrics for Disconnection types diff --git a/crates/net/network/src/transactions.rs b/crates/net/network/src/transactions.rs index 8cf34a67aa..b15d8a23a1 100644 --- a/crates/net/network/src/transactions.rs +++ b/crates/net/network/src/transactions.rs @@ -158,6 +158,10 @@ where TransactionsHandle { manager_tx: self.command_tx.clone() } } + fn update_import_metrics(&self) { + self.metrics.pending_pool_imports.set(self.pool_imports.len() as f64); + } + /// Request handler for an incoming request for transactions fn on_get_pooled_transactions( &mut self, @@ -538,6 +542,8 @@ where } } + this.update_import_metrics(); + // Advance all imports while let Poll::Ready(Some(import_res)) = this.pool_imports.poll_next_unpin(cx) { match import_res { @@ -558,6 +564,8 @@ where } } + this.update_import_metrics(); + // handle and propagate new transactions let mut new_txs = Vec::new(); while let Poll::Ready(Some(hash)) = this.pending_transactions.poll_next_unpin(cx) {