Skip to content

Commit

Permalink
feat: add storage label to all storage metrics (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored Jun 25, 2024
1 parent 3b02a69 commit 3a52cc4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
31 changes: 18 additions & 13 deletions src/eth/storage/stratus_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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()),
);
})
}

Expand Down Expand Up @@ -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());
})
}

Expand All @@ -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 {
Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand All @@ -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());
})
}

Expand Down
31 changes: 14 additions & 17 deletions src/infra/metrics/metrics_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,57 @@ 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.
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.
Expand Down

0 comments on commit 3a52cc4

Please sign in to comment.