diff --git a/finalizer/src/lib.rs b/finalizer/src/lib.rs index 708ef0f4..f00ce708 100644 --- a/finalizer/src/lib.rs +++ b/finalizer/src/lib.rs @@ -86,7 +86,7 @@ where ) -> Self { let withdrawals_meterer = withdrawals_meterer::WithdrawalsMeter::new( pgpool.clone(), - "era_withdrawal_finalizer_withdrawn_tokens", + "era_withdrawal_finalizer_meter", ); let tx_fee_limit = ethers::utils::parse_ether(TX_FEE_LIMIT) .expect("{TX_FEE_LIMIT} ether is a parsable amount; qed"); @@ -216,7 +216,7 @@ where if let Err(e) = self .withdrawals_meterer - .meter_finalized_withdrawals_storage(&ids) + .meter_withdrawals_storage(&ids) .await { vlog::error!("Failed to meter the withdrawals: {e}"); diff --git a/watcher/src/lib.rs b/watcher/src/lib.rs index a414cbf6..93044c24 100644 --- a/watcher/src/lib.rs +++ b/watcher/src/lib.rs @@ -42,7 +42,7 @@ where pub fn new(l2_provider: Arc, pgpool: PgPool) -> Self { let withdrawals_meterer = withdrawals_meterer::WithdrawalsMeter::new( pgpool.clone(), - "era_withdrawn_tokens_amounts_tracker", + "era_withdrawal_finalizer_watcher_meter", ); Self { @@ -316,7 +316,7 @@ async fn process_withdrawals_in_block( } if let Err(e) = withdrawals_meterer - .meter_finalized_withdrawals(&stored_withdrawals) + .meter_withdrawals(&stored_withdrawals) .await { vlog::error!("Failed to meter requested withdrawals: {e}"); diff --git a/withdrawals-meterer/src/lib.rs b/withdrawals-meterer/src/lib.rs index 889e1c34..380b2312 100644 --- a/withdrawals-meterer/src/lib.rs +++ b/withdrawals-meterer/src/lib.rs @@ -16,7 +16,7 @@ use storage::StoredWithdrawal; pub struct WithdrawalsMeter { pool: PgPool, token_decimals: HashMap, - metric_name: &'static str, + component_name: &'static str, } impl WithdrawalsMeter { @@ -25,26 +25,25 @@ impl WithdrawalsMeter { /// # Arguments /// /// * `pool`: DB connection pool - /// * `metric_name`: Name of the metric to meter to - pub fn new(pool: PgPool, metric_name: &'static str) -> Self { + /// * `component_name`: Name of the component that does metering, metric names will be + /// derived from it + pub fn new(pool: PgPool, component_name: &'static str) -> Self { let mut token_decimals = HashMap::new(); token_decimals.insert(ETH_TOKEN_ADDRESS, 18_u32); Self { pool, token_decimals, - metric_name, + component_name, } } + /// Given a set of withdrawal ids meter all of them to a metric /// with a given name. - pub async fn meter_finalized_withdrawals_storage( - &mut self, - ids: &[i64], - ) -> Result<(), storage::Error> { + pub async fn meter_withdrawals_storage(&mut self, ids: &[i64]) -> Result<(), storage::Error> { let withdrawals = storage::get_withdrawals(&self.pool, ids).await?; - self.meter_finalized_withdrawals(&withdrawals).await?; + self.meter_withdrawals(&withdrawals).await?; Ok(()) } @@ -54,7 +53,7 @@ impl WithdrawalsMeter { /// /// This function returns only storage error, all formatting, etc /// errors will be just logged. - pub async fn meter_finalized_withdrawals( + pub async fn meter_withdrawals( &mut self, withdrawals: &[StoredWithdrawal], ) -> Result<(), storage::Error> { @@ -90,7 +89,7 @@ impl WithdrawalsMeter { }; metrics::increment_gauge!( - self.metric_name, + format!("{}_withdrawals", self.component_name), formatted_f64, "token" => format!("{:?}", w.event.token) )