Skip to content

Commit

Permalink
fix: reset metrics when builder re-initialized. (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d authored Dec 13, 2024
1 parent cc2bf7f commit 5e77dfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/builder/src/bundle_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ where
error!("Bundle send error {error:?}");
self.metrics.bundle_txns_failed.increment(1);
state.bundle_error(error);
state.transaction_tracker.reset().await;
}
}

Expand Down
6 changes: 6 additions & 0 deletions crates/builder/src/transaction_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ where
);
let sent_tx = self.sender.send_transaction(tx, expected_storage).await;

self.update_metrics();

match sent_tx {
Ok(sent_tx) => {
info!(
Expand Down Expand Up @@ -495,6 +497,10 @@ where
async fn reset(&mut self) {
let nonce = self.get_external_nonce().await.unwrap_or(self.nonce);
self.set_nonce_and_clear_state(nonce);
// reset metrics when tracker reset.
self.metrics.num_pending_transactions.set(0);
self.metrics.current_max_fee_per_gas.set(0);
self.metrics.max_priority_fee_per_gas.set(0);
}

fn abandon(&mut self) {
Expand Down

0 comments on commit 5e77dfe

Please sign in to comment.