forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmetrics.rs
142 lines (125 loc) · 5.38 KB
/
metrics.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//! Transaction pool metrics.
use reth_metrics::{
metrics::{Counter, Gauge, Histogram},
Metrics,
};
/// Transaction pool metrics
#[derive(Metrics)]
#[metrics(scope = "transaction_pool")]
pub struct TxPoolMetrics {
/// Number of transactions inserted in the pool
pub(crate) inserted_transactions: Counter,
/// Number of invalid transactions
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,
/// Number of transactions in the blob sub-pool
pub(crate) blob_pool_transactions: Gauge,
/// Total amount of memory used by the transactions in the blob sub-pool in bytes
pub(crate) blob_pool_size_bytes: Gauge,
/// Number of all transactions of all sub-pools: pending + basefee + queued + blob
pub(crate) total_transactions: Gauge,
/// Number of all legacy transactions in the pool
pub(crate) total_legacy_transactions: Gauge,
/// Number of all EIP-2930 transactions in the pool
pub(crate) total_eip2930_transactions: Gauge,
/// Number of all EIP-1559 transactions in the pool
pub(crate) total_eip1559_transactions: Gauge,
/// Number of all EIP-4844 transactions in the pool
pub(crate) total_eip4844_transactions: Gauge,
/// Number of all EIP-7702 transactions in the pool
pub(crate) total_eip7702_transactions: Gauge,
/// How often the pool was updated after the canonical state changed
pub(crate) performed_state_updates: Counter,
/// Counter for the number of pending transactions evicted
pub(crate) pending_transactions_evicted: Counter,
/// Counter for the number of basefee transactions evicted
pub(crate) basefee_transactions_evicted: Counter,
/// Counter for the number of blob transactions evicted
pub(crate) blob_transactions_evicted: Counter,
/// Counter for the number of queued transactions evicted
pub(crate) queued_transactions_evicted: Counter,
}
/// Transaction pool blobstore metrics
#[derive(Metrics)]
#[metrics(scope = "transaction_pool")]
pub struct BlobStoreMetrics {
/// Number of failed inserts into the blobstore
pub(crate) blobstore_failed_inserts: Counter,
/// Number of failed deletes into the blobstore
pub(crate) blobstore_failed_deletes: Counter,
/// The number of bytes the blobs in the blobstore take up
pub(crate) blobstore_byte_size: Gauge,
/// How many blobs are currently in the blobstore
pub(crate) blobstore_entries: Gauge,
}
/// Transaction pool maintenance metrics
#[derive(Metrics)]
#[metrics(scope = "transaction_pool")]
pub struct MaintainPoolMetrics {
/// Gauge indicating the number of addresses with pending updates in the pool,
/// requiring their account information to be fetched.
pub(crate) dirty_accounts: Gauge,
/// Counter for the number of times the pool state diverged from the canonical blockchain
/// state.
pub(crate) drift_count: Counter,
/// Counter for the number of transactions reinserted into the pool following a blockchain
/// reorganization (reorg).
pub(crate) reinserted_transactions: Counter,
/// Counter for the number of finalized blob transactions that have been removed from tracking.
pub(crate) deleted_tracked_finalized_blobs: Counter,
}
impl MaintainPoolMetrics {
#[inline]
pub(crate) fn set_dirty_accounts_len(&self, count: usize) {
self.dirty_accounts.set(count as f64);
}
#[inline]
pub(crate) fn inc_reinserted_transactions(&self, count: usize) {
self.reinserted_transactions.increment(count as u64);
}
#[inline]
pub(crate) fn inc_deleted_tracked_blobs(&self, count: usize) {
self.deleted_tracked_finalized_blobs.increment(count as u64);
}
#[inline]
pub(crate) fn inc_drift(&self) {
self.drift_count.increment(1);
}
}
/// All Transactions metrics
#[derive(Metrics)]
#[metrics(scope = "transaction_pool")]
pub struct AllTransactionsMetrics {
/// Number of all transactions by hash in the pool
pub(crate) all_transactions_by_hash: Gauge,
/// Number of all transactions by id in the pool
pub(crate) all_transactions_by_id: Gauge,
/// Number of all transactions by all senders in the pool
pub(crate) all_transactions_by_all_senders: Gauge,
/// Number of blob transactions nonce gaps.
pub(crate) blob_transactions_nonce_gaps: Counter,
/// The current blob base fee
pub(crate) blob_base_fee: Gauge,
/// The current base fee
pub(crate) base_fee: Gauge,
}
/// Transaction pool validation metrics
#[derive(Metrics)]
#[metrics(scope = "transaction_pool")]
pub struct TxPoolValidationMetrics {
/// How long to successfully validate a blob
pub(crate) blob_validation_duration: Histogram,
}