diff --git a/crates/net/network/src/metrics.rs b/crates/net/network/src/metrics.rs index 241a778869..ba9efdff54 100644 --- a/crates/net/network/src/metrics.rs +++ b/crates/net/network/src/metrics.rs @@ -131,6 +131,8 @@ pub struct TransactionsManagerMetrics { /// capacity. Note, this is not a limit to the number of inflight requests, but a health /// measure. pub(crate) capacity_pending_pool_imports: Counter, + /// The time it took to prepare transactions for import. This is mostly sender recovery. + pub(crate) pool_import_prepare_duration: Histogram, /* ================ POLL DURATION ================ */ diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 11b0e14dca..1710525526 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -1338,6 +1338,8 @@ where let Some(peer) = self.peers.get_mut(&peer_id) else { return }; let mut transactions = transactions.0; + let start = Instant::now(); + // mark the transactions as received self.transaction_fetcher .remove_hashes_from_transaction_fetcher(transactions.iter().map(|tx| tx.tx_hash())); @@ -1459,6 +1461,8 @@ where if num_already_seen_by_peer > 0 { self.report_already_seen(peer_id); } + + self.metrics.pool_import_prepare_duration.record(start.elapsed()); } /// Processes a [`FetchEvent`].