mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2025-04-04 15:35:18 +00:00
add metrics in log sync package
This commit is contained in:
parent
c1f465e009
commit
24d41f32b2
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -4538,6 +4538,8 @@ dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"jsonrpsee",
|
||||
"lazy_static",
|
||||
"metrics",
|
||||
"serde_json",
|
||||
"shared_types",
|
||||
"storage",
|
||||
|
@ -22,3 +22,5 @@ contract-interface = { path = "../../common/contract-interface" }
|
||||
futures-core = "0.3.28"
|
||||
futures-util = "0.3.28"
|
||||
thiserror = "1.0.44"
|
||||
lazy_static = "1.4.0"
|
||||
metrics = { workspace = true }
|
||||
|
7
node/log_entry_sync/src/sync_manager/metrics.rs
Normal file
7
node/log_entry_sync/src/sync_manager/metrics.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use metrics::{register_timer, Timer};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref STORE_PUT_TX: Arc<dyn Timer> = register_timer("log_entry_sync_store_put_tx");
|
||||
}
|
@ -11,7 +11,7 @@ use std::collections::BTreeMap;
|
||||
use std::fmt::Debug;
|
||||
use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration, Instant};
|
||||
use storage::log_store::{tx_store::BlockHashAndSubmissionIndex, Store};
|
||||
use task_executor::{ShutdownReason, TaskExecutor};
|
||||
use tokio::sync::broadcast;
|
||||
@ -358,7 +358,11 @@ impl LogSyncManager {
|
||||
}
|
||||
|
||||
async fn put_tx_inner(&mut self, tx: Transaction) -> bool {
|
||||
if let Err(e) = self.store.put_tx(tx.clone()) {
|
||||
let start_time = Instant::now();
|
||||
let result = self.store.put_tx(tx.clone());
|
||||
metrics::STORE_PUT_TX.update_since(start_time);
|
||||
|
||||
if let Err(e) = result {
|
||||
error!("put_tx error: e={:?}", e);
|
||||
false
|
||||
} else {
|
||||
@ -458,3 +462,4 @@ pub(crate) mod config;
|
||||
mod data_cache;
|
||||
mod log_entry_fetcher;
|
||||
mod log_query;
|
||||
mod metrics;
|
||||
|
Loading…
Reference in New Issue
Block a user