add detailed metrics for storage layer

This commit is contained in:
Peter Zhang 2024-10-29 10:09:04 +08:00
parent 16c587a470
commit 06d8071566
4 changed files with 8 additions and 0 deletions

View File

@ -8,4 +8,6 @@ lazy_static::lazy_static! {
pub static ref STORE_PUT_TX: Arc<dyn Timer> = register_timer("log_entry_sync_manager_put_tx_inner"); pub static ref STORE_PUT_TX: Arc<dyn Timer> = register_timer("log_entry_sync_manager_put_tx_inner");
pub static ref STORE_PUT_TX_SPEED_IN_BYTES: Arc<dyn Gauge<usize>> = GaugeUsize::register("log_entry_sync_manager_put_tx_speed_in_bytes"); pub static ref STORE_PUT_TX_SPEED_IN_BYTES: Arc<dyn Gauge<usize>> = GaugeUsize::register("log_entry_sync_manager_put_tx_speed_in_bytes");
pub static ref FlOW_CONTRACT_ROOT: Arc<dyn Timer> = register_timer("log_manager_flow_contract_root");
} }

View File

@ -517,6 +517,7 @@ impl LogSyncManager {
// If the call fails, we won't check the root here and return `true` directly. // If the call fails, we won't check the root here and return `true` directly.
let flow_contract = self.log_fetcher.flow_contract(); let flow_contract = self.log_fetcher.flow_contract();
let flow_time = Instant::now();
match flow_contract match flow_contract
.get_flow_root_by_tx_seq(tx.seq.into()) .get_flow_root_by_tx_seq(tx.seq.into())
.call() .call()
@ -547,6 +548,7 @@ impl LogSyncManager {
warn!(?e, "fail to read the on-chain flow root"); warn!(?e, "fail to read the on-chain flow root");
} }
} }
metrics::FlOW_CONTRACT_ROOT.update_since(flow_time);
metrics::STORE_PUT_TX_SPEED_IN_BYTES metrics::STORE_PUT_TX_SPEED_IN_BYTES
.update((tx.size / start_time.elapsed().as_millis() as u64) as usize); .update((tx.size / start_time.elapsed().as_millis() as u64) as usize);

View File

@ -315,6 +315,7 @@ impl LogStoreWrite for LogManager {
} }
fn finalize_tx_with_hash(&self, tx_seq: u64, tx_hash: H256) -> crate::error::Result<bool> { fn finalize_tx_with_hash(&self, tx_seq: u64, tx_hash: H256) -> crate::error::Result<bool> {
let start_time = Instant::now();
trace!( trace!(
"finalize_tx_with_hash: tx_seq={} tx_hash={:?}", "finalize_tx_with_hash: tx_seq={} tx_hash={:?}",
tx_seq, tx_seq,
@ -343,6 +344,7 @@ impl LogStoreWrite for LogManager {
if same_root_seq_list.first() == Some(&tx_seq) { if same_root_seq_list.first() == Some(&tx_seq) {
self.copy_tx_and_finalize(tx_seq, same_root_seq_list[1..].to_vec())?; self.copy_tx_and_finalize(tx_seq, same_root_seq_list[1..].to_vec())?;
} }
metrics::FINALIZE_TX_WITH_HASH.update_since(start_time);
Ok(true) Ok(true)
} else { } else {
bail!("finalize tx hash with data missing: tx_seq={}", tx_seq) bail!("finalize tx hash with data missing: tx_seq={}", tx_seq)

View File

@ -34,4 +34,6 @@ lazy_static::lazy_static! {
register_timer("log_store_flow_store_put_entry_batch_list"); register_timer("log_store_flow_store_put_entry_batch_list");
pub static ref APPEND_ENTRIES: Arc<dyn Timer> = register_timer("log_store_flow_store_append_entries"); pub static ref APPEND_ENTRIES: Arc<dyn Timer> = register_timer("log_store_flow_store_append_entries");
pub static ref FINALIZE_TX_WITH_HASH: Arc<dyn Timer> = register_timer("log_store_log_manager_finalize_tx_with_hash");
} }