Add metrics for observing tx fetch outcome (#7401)

This commit is contained in:
Emilia Hane
2024-03-30 22:17:54 +01:00
committed by GitHub
parent 9de7b4152e
commit bfadc26b37
2 changed files with 11 additions and 1 deletions

View File

@ -200,7 +200,12 @@ pub struct TransactionFetcherMetrics {
pub(crate) egress_peer_channel_full: Counter,
/// Total number of hashes pending fetch.
pub(crate) hashes_pending_fetch: Gauge,
/// Total number of fetched transactions.
pub(crate) fetched_transactions: Counter,
/// Total number of transactions that were received in
/// [`PooledTransactions`](reth_eth_wire::PooledTransactions) responses, that weren't
/// requested.
pub(crate) unsolicited_transactions: Counter,
/* ================ SEARCH DURATION ================ */
/// Time spent searching for an idle peer in call to
/// [`TransactionFetcher::find_any_idle_fallback_peer_for_any_pending_hash`](crate::transactions::TransactionFetcher::find_any_idle_fallback_peer_for_any_pending_hash).

View File

@ -944,6 +944,10 @@ impl TransactionFetcher {
let (verification_outcome, verified_payload) =
payload.verify(&requested_hashes, &peer_id);
let unsolicited = unverified_len - verified_payload.len();
if unsolicited > 0 {
self.metrics.unsolicited_transactions.increment(unsolicited as u64);
}
if verification_outcome == VerificationOutcome::ReportPeer {
// todo: report peer for sending hashes that weren't requested
trace!(target: "net::tx",
@ -997,6 +1001,7 @@ impl TransactionFetcher {
true
});
fetched.shrink_to_fit();
self.metrics.fetched_transactions.increment(fetched.len() as u64);
if fetched.len() < requested_hashes_len {
trace!(target: "net::tx",