mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(net) Add TransactionsManager Metrics (#769)
* Added TransactionsManager Metrics * Remove tracking of peers * Add propagated_transactions
This commit is contained in:
@ -32,3 +32,11 @@ pub struct NetworkMetrics {
|
||||
/// Number of invalid/malformed messages received from peers
|
||||
pub(crate) invalid_messages_received: Counter,
|
||||
}
|
||||
|
||||
/// Metrics for the TransactionManager
|
||||
#[derive(Metrics)]
|
||||
#[metrics(scope = "network")]
|
||||
pub struct TransactionsManagerMetrics {
|
||||
/// Total number of propagated transactions
|
||||
pub(crate) propagated_transactions: Counter,
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ use crate::{
|
||||
cache::LruCache,
|
||||
manager::NetworkEvent,
|
||||
message::{PeerRequest, PeerRequestSender},
|
||||
metrics::TransactionsManagerMetrics,
|
||||
network::NetworkHandleMessage,
|
||||
peers::ReputationChangeKind,
|
||||
NetworkHandle,
|
||||
@ -101,6 +102,8 @@ pub struct TransactionsManager<Pool> {
|
||||
pending_transactions: ReceiverStream<TxHash>,
|
||||
/// Incoming events from the [`NetworkManager`](crate::NetworkManager).
|
||||
transaction_events: UnboundedReceiverStream<NetworkTransactionEvent>,
|
||||
/// TransactionsManager metrics
|
||||
metrics: TransactionsManagerMetrics,
|
||||
}
|
||||
|
||||
impl<Pool: TransactionPool> TransactionsManager<Pool> {
|
||||
@ -130,6 +133,7 @@ impl<Pool: TransactionPool> TransactionsManager<Pool> {
|
||||
command_rx: UnboundedReceiverStream::new(command_rx),
|
||||
pending_transactions: ReceiverStream::new(pending),
|
||||
transaction_events: UnboundedReceiverStream::new(from_network),
|
||||
metrics: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,6 +239,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// Update propagated transactions metrics
|
||||
self.metrics.propagated_transactions.increment(propagated.0.len() as u64);
|
||||
|
||||
propagated
|
||||
}
|
||||
|
||||
|
||||
@ -89,6 +89,7 @@ This list may be non-exhaustive.
|
||||
- `network.total_incoming_connections`: Total number of incoming connections handled
|
||||
- `network.total_outgoing_connections`: Total number of outgoing connections established
|
||||
- `network.invalid_messages_received`: Number of invalid/malformed messages received from peers
|
||||
- `network.propagated_transactions`: Total number of propagated transactions
|
||||
|
||||
[metrics]: https://docs.rs/metrics
|
||||
[metrics.Key]: https://docs.rs/metrics/latest/metrics/struct.Key.html
|
||||
|
||||
Reference in New Issue
Block a user