From 3a52cc4a54086fa0da6146dbfc7f15bdcefb7ac9 Mon Sep 17 00:00:00 2001 From: Renato Dinhani <101204870+dinhani-cw@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:28:39 -0300 Subject: [PATCH] feat: add storage label to all storage metrics (#1234) --- src/eth/storage/stratus_storage.rs | 31 ++++++++++++++---------- src/infra/metrics/metrics_definitions.rs | 31 +++++++++++------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/eth/storage/stratus_storage.rs b/src/eth/storage/stratus_storage.rs index bd62ef5e8..3b6df8e85 100644 --- a/src/eth/storage/stratus_storage.rs +++ b/src/eth/storage/stratus_storage.rs @@ -123,7 +123,7 @@ impl StratusStorage { tracing::debug!(storage = %label::TEMP, "reading active block number"); timed(|| self.temp.read_active_block_number()).with(|m| { - metrics::inc_storage_read_active_block_number(m.elapsed, m.result.is_ok()); + metrics::inc_storage_read_active_block_number(m.elapsed, label::TEMP, m.result.is_ok()); }) } @@ -132,7 +132,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, "reading mined block number"); timed(|| self.perm.read_mined_block_number()).with(|m| { - metrics::inc_storage_read_mined_block_number(m.elapsed, m.result.is_ok()); + metrics::inc_storage_read_mined_block_number(m.elapsed, label::PERM, m.result.is_ok()); }) } @@ -144,7 +144,7 @@ impl StratusStorage { tracing::debug!(storage = &label::TEMP, %number, "setting active block number"); timed(|| self.temp.set_active_block_number(number)).with(|m| { - metrics::inc_storage_set_active_block_number(m.elapsed, m.result.is_ok()); + metrics::inc_storage_set_active_block_number(m.elapsed, label::TEMP, m.result.is_ok()); }) } @@ -169,7 +169,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, %number, "setting mined block number"); timed(|| self.perm.set_mined_block_number(number)).with(|m| { - metrics::inc_storage_set_mined_block_number(m.elapsed, m.result.is_ok()); + metrics::inc_storage_set_mined_block_number(m.elapsed, label::PERM, m.result.is_ok()); }) } @@ -181,7 +181,7 @@ impl StratusStorage { tracing::debug!(storage = %label::TEMP, number = %block.number(), "setting active external block"); timed(|| self.temp.set_active_external_block(block)).with(|m| { - metrics::inc_storage_set_active_external_block(m.elapsed, m.result.is_ok()); + metrics::inc_storage_set_active_external_block(m.elapsed, label::TEMP, m.result.is_ok()); }) } @@ -198,7 +198,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, accounts = ?missing_accounts, "saving initial accounts"); timed(|| self.perm.save_accounts(missing_accounts)).with(|m| { - metrics::inc_storage_save_accounts(m.elapsed, m.result.is_ok()); + metrics::inc_storage_save_accounts(m.elapsed, label::PERM, m.result.is_ok()); }) } @@ -207,7 +207,12 @@ impl StratusStorage { tracing::debug!(storage = %label::TEMP, "checking conflicts"); timed(|| self.temp.check_conflicts(execution)).with(|m| { - metrics::inc_storage_check_conflicts(m.elapsed, m.result.is_ok(), m.result.as_ref().is_ok_and(|conflicts| conflicts.is_some())); + metrics::inc_storage_check_conflicts( + m.elapsed, + label::TEMP, + m.result.is_ok(), + m.result.as_ref().is_ok_and(|conflicts| conflicts.is_some()), + ); }) } @@ -302,7 +307,7 @@ impl StratusStorage { tracing::debug!(storage = %label::TEMP, hash = %tx.hash(), "saving execution"); timed(|| self.temp.save_execution(tx)).with(|m| { - metrics::inc_storage_save_execution(m.elapsed, m.result.is_ok()); + metrics::inc_storage_save_execution(m.elapsed, label::TEMP, m.result.is_ok()); }) } @@ -311,7 +316,7 @@ impl StratusStorage { tracing::debug!(storage = %label::TEMP, "finishing active block"); let result = timed(|| self.temp.finish_block()).with(|m| { - metrics::inc_storage_finish_block(m.elapsed, m.result.is_ok()); + metrics::inc_storage_finish_block(m.elapsed, label::TEMP, m.result.is_ok()); }); if let Ok(ref block) = result { @@ -328,7 +333,7 @@ impl StratusStorage { let (label_size_by_tx, label_size_by_gas) = (block.label_size_by_transactions(), block.label_size_by_gas()); timed(|| self.perm.save_block(block)).with(|m| { - metrics::inc_storage_save_block(m.elapsed, label_size_by_tx, label_size_by_gas, m.result.is_ok()); + metrics::inc_storage_save_block(m.elapsed, label::PERM, label_size_by_tx, label_size_by_gas, m.result.is_ok()); }) } @@ -337,7 +342,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, ?selection, "reading block"); timed(|| self.perm.read_block(selection)).with(|m| { - metrics::inc_storage_read_block(m.elapsed, m.result.is_ok()); + metrics::inc_storage_read_block(m.elapsed, label::PERM, m.result.is_ok()); }) } @@ -347,7 +352,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, %hash, "reading transaction"); timed(|| self.perm.read_mined_transaction(hash)).with(|m| { - metrics::inc_storage_read_mined_transaction(m.elapsed, m.result.is_ok()); + metrics::inc_storage_read_mined_transaction(m.elapsed, label::PERM, m.result.is_ok()); }) } @@ -356,7 +361,7 @@ impl StratusStorage { tracing::debug!(storage = %label::PERM, ?filter, "reading logs"); timed(|| self.perm.read_logs(filter)).with(|m| { - metrics::inc_storage_read_logs(m.elapsed, m.result.is_ok()); + metrics::inc_storage_read_logs(m.elapsed, label::PERM, m.result.is_ok()); }) } diff --git a/src/infra/metrics/metrics_definitions.rs b/src/infra/metrics/metrics_definitions.rs index 9d446c99d..d7b496ff1 100644 --- a/src/infra/metrics/metrics_definitions.rs +++ b/src/infra/metrics/metrics_definitions.rs @@ -22,28 +22,28 @@ metrics! { group: storage_read, "Time to execute storage check_conflicts operation." - histogram_duration storage_check_conflicts{success, conflicted}, + histogram_duration storage_check_conflicts{storage, success, conflicted}, "Time to execute storage read_active_block_number operation." - histogram_duration storage_read_active_block_number{success}, + histogram_duration storage_read_active_block_number{storage, success}, "Time to execute storage read_mined_block_number operation." - histogram_duration storage_read_mined_block_number{success}, + histogram_duration storage_read_mined_block_number{storage, success}, "Time to execute storage read_account operation." histogram_duration storage_read_account{storage, point_in_time, success}, "Time to execute storage read_block operation." - histogram_duration storage_read_block{success}, + histogram_duration storage_read_block{storage, success}, "Time to execute storage read_logs operation." - histogram_duration storage_read_logs{success}, + histogram_duration storage_read_logs{storage, success}, "Time to execute storage read_slot operation." histogram_duration storage_read_slot{storage, point_in_time, success}, "Time to execute storage read_mined_transaction operation." - histogram_duration storage_read_mined_transaction{success} + histogram_duration storage_read_mined_transaction{storage, success} } // Storage writes. @@ -51,31 +51,28 @@ metrics! { group: storage_write, "Time to execute storage set_active_block_number operation." - histogram_duration storage_set_active_block_number{success}, + histogram_duration storage_set_active_block_number{storage, success}, "Time to execute storage set_mined_block_number operation." - histogram_duration storage_set_mined_block_number{success}, + histogram_duration storage_set_mined_block_number{storage, success}, "Time to execute storage save_accounts operation." - histogram_duration storage_save_accounts{success}, + histogram_duration storage_save_accounts{storage, success}, "Time to execute storage save_account_changes operation." - histogram_duration storage_save_execution{success}, - - "Time to execute storage flush operation." - histogram_duration storage_flush{kind, success}, + histogram_duration storage_save_execution{storage, success}, "Time to execute storage set_active_external_block operation." - histogram_duration storage_set_active_external_block{success}, + histogram_duration storage_set_active_external_block{storage, success}, "Time to execute storage finish_block operation." - histogram_duration storage_finish_block{success}, + histogram_duration storage_finish_block{storage, success}, "Time to execute storage save_block operation." - histogram_duration storage_save_block{size_by_tx, size_by_gas, success}, + histogram_duration storage_save_block{storage, size_by_tx, size_by_gas, success}, "Time to execute storage reset operation." - histogram_duration storage_reset{kind, success} + histogram_duration storage_reset{storage, success} } // Importer online metrics.