Skip to content

Commit ec98ae5

Browse files
authored
feat(metrics): record eip1559 fees estimations (#1234)
Record metrics for every EIP-1559 fees estimation. Helps us to see the surges in fees that can lead to signers being out of balance.
1 parent b7f01dc commit ec98ae5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/transactions/metrics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ pub struct TransactionServiceMetrics {
4444
pub blocks_until_inclusion: Histogram,
4545
/// How long transactions have spent in queue before being sent.
4646
pub time_in_queue: Histogram,
47+
/// Maximum estimated fee per gas, in wei.
48+
pub max_fee_per_gas: Histogram,
49+
/// Maximum estimated priority fee per gas, in wei.
50+
pub max_priority_fee_per_gas: Histogram,
4751
}
4852

4953
/// Metrics of an individual signer, should be labeled with the signer address and chain ID.

src/transactions/signer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ impl Signer {
269269
/// See also [`FeeConfig::adjusted_eip1559_estimation`]
270270
async fn estimate_eip1559_fees(&self) -> TransportResult<Eip1559Estimation> {
271271
let fees = self.provider.estimate_eip1559_fees().await?;
272-
Ok(self.fees.adjusted_eip1559_estimation(fees))
272+
let adjusted_fees = self.fees.adjusted_eip1559_estimation(fees);
273+
self.metrics.max_fee_per_gas.record(adjusted_fees.max_fee_per_gas as f64);
274+
self.metrics.max_priority_fee_per_gas.record(adjusted_fees.max_priority_fee_per_gas as f64);
275+
Ok(adjusted_fees)
273276
}
274277

275278
/// Invoked when a transaction is confirmed.

0 commit comments

Comments
 (0)