Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/net/network/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
9 changes: 9 additions & 0 deletions crates/net/network/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -609,6 +617,7 @@ where
}
}

this.update_request_metrics();
this.update_import_metrics();

// Advance all imports
Expand Down
Loading