feat: add metrics for inflight get pooled tx requests (#4547)

This commit is contained in:
Matthias Seitz
2023-09-11 13:17:39 +02:00
committed by GitHub
parent fc9f1168bc
commit 8cb92e35f1
2 changed files with 11 additions and 0 deletions

View File

@ -67,6 +67,8 @@ pub struct TransactionsManagerMetrics {
pub(crate) messages_with_already_seen_transactions: Counter,
/// Number of transactions about to be imported into the pool.
pub(crate) pending_pool_imports: Gauge,
/// Currently active outgoing GetPooledTransactions requests.
pub(crate) inflight_transaction_requests: Gauge,
/// How often we failed to send a request to the peer because the channel was full.
pub(crate) egress_peer_channel_full: Counter,
}

View File

@ -174,10 +174,16 @@ where
TransactionsHandle { manager_tx: self.command_tx.clone() }
}
#[inline]
fn update_import_metrics(&self) {
self.metrics.pending_pool_imports.set(self.pool_imports.len() as f64);
}
#[inline]
fn update_request_metrics(&self) {
self.metrics.inflight_transaction_requests.set(self.inflight_requests.len() as f64);
}
/// Request handler for an incoming request for transactions
fn on_get_pooled_transactions(
&mut self,
@ -591,6 +597,8 @@ where
this.on_network_tx_event(event);
}
this.update_request_metrics();
// Advance all requests.
while let Poll::Ready(Some(GetPooledTxResponse { peer_id, result })) =
this.inflight_requests.poll_next_unpin(cx)
@ -609,6 +617,7 @@ where
}
}
this.update_request_metrics();
this.update_import_metrics();
// Advance all imports