mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(txpool): add sub-pools length and size metrics (#2598)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
//! Transaction pool metrics.
|
||||
|
||||
use metrics::Counter;
|
||||
use metrics::{Counter, Gauge};
|
||||
use reth_metrics_derive::Metrics;
|
||||
|
||||
/// Transaction pool metrics
|
||||
@ -13,4 +13,19 @@ pub struct TxPoolMetrics {
|
||||
pub(crate) invalid_transactions: Counter,
|
||||
/// Number of removed transactions from the pool
|
||||
pub(crate) removed_transactions: Counter,
|
||||
|
||||
/// Number of transactions in the pending sub-pool
|
||||
pub(crate) pending_pool_transactions: Gauge,
|
||||
/// Total amount of memory used by the transactions in the pending sub-pool in bytes
|
||||
pub(crate) pending_pool_size_bytes: Gauge,
|
||||
|
||||
/// Number of transactions in the basefee sub-pool
|
||||
pub(crate) basefee_pool_transactions: Gauge,
|
||||
/// Total amount of memory used by the transactions in the basefee sub-pool in bytes
|
||||
pub(crate) basefee_pool_size_bytes: Gauge,
|
||||
|
||||
/// Number of transactions in the queued sub-pool
|
||||
pub(crate) queued_pool_transactions: Gauge,
|
||||
/// Total amount of memory used by the transactions in the queued sub-pool in bytes
|
||||
pub(crate) queued_pool_size_bytes: Gauge,
|
||||
}
|
||||
|
||||
@ -253,9 +253,23 @@ impl<T: TransactionOrdering> TxPool<T> {
|
||||
// Process the sub-pool updates
|
||||
let UpdateOutcome { promoted, discarded } = self.process_updates(updates);
|
||||
|
||||
// update the metrics after the update
|
||||
self.update_size_metrics();
|
||||
|
||||
OnNewCanonicalStateOutcome { block_hash, mined: mined_transactions, promoted, discarded }
|
||||
}
|
||||
|
||||
/// Update sub-pools size metrics.
|
||||
pub(crate) fn update_size_metrics(&mut self) {
|
||||
let stats = self.size();
|
||||
self.metrics.pending_pool_transactions.set(stats.pending as f64);
|
||||
self.metrics.pending_pool_size_bytes.set(stats.pending_size as f64);
|
||||
self.metrics.basefee_pool_transactions.set(stats.basefee as f64);
|
||||
self.metrics.basefee_pool_size_bytes.set(stats.basefee_size as f64);
|
||||
self.metrics.queued_pool_transactions.set(stats.queued as f64);
|
||||
self.metrics.queued_pool_size_bytes.set(stats.queued_size as f64);
|
||||
}
|
||||
|
||||
/// Adds the transaction into the pool.
|
||||
///
|
||||
/// This pool consists of two three-pools: `Queued`, `Pending` and `BaseFee`.
|
||||
|
||||
@ -75,8 +75,14 @@ This list may be non-exhaustive.
|
||||
#### Component: Transaction Pool
|
||||
|
||||
- `transaction_pool.inserted_transactions`: Number of transactions inserted in the pool
|
||||
- `transaction_pool.invalid_transactions`: Number of invalid transactions
|
||||
- `transaction_pool.invalid_transactions`: Number of invalid transactions
|
||||
- `transaction_pool.removed_transactions`: Number of removed transactions from the pool
|
||||
- `transaction_pool.pending_pool_transactions`: Number of transactions in the pending sub-pool
|
||||
- `transaction_pool.pending_pool_size_bytes`: Total amount of memory used by the transactions in the pending sub-pool in bytes
|
||||
- `transaction_pool.basefee_pool_transactions`: Number of transactions in the basefee sub-pool
|
||||
- `transaction_pool.basefee_pool_size_bytes`: Total amount of memory used by the transactions in the basefee sub-pool in bytes
|
||||
- `transaction_pool.queued_pool_transactions`: Number of transactions in the queued sub-pool
|
||||
- `transaction_pool.queued_pool_size_bytes`: Total amount of memory used by the transactions in the queued sub-pool in bytes
|
||||
|
||||
#### Component: Network
|
||||
|
||||
|
||||
Reference in New Issue
Block a user