mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: metrics (#92)
* feat(stages): `stage.progress` metric * docs: metrics
This commit is contained in:
@ -17,6 +17,7 @@ tracing = "0.1.36"
|
||||
tracing-futures = "0.2.5"
|
||||
tokio = { version = "1.21.2", features = ["sync"] }
|
||||
aquamarine = "0.1.12"
|
||||
metrics = "0.20.1"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "*", features = ["rt", "sync", "macros"] }
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
use metrics::counter;
|
||||
use reth_interfaces::db::{tables::SyncStage, DbTx, DbTxMut, Error as DbError};
|
||||
use reth_primitives::BlockNumber;
|
||||
use std::fmt::Display;
|
||||
@ -26,6 +27,7 @@ impl StageId {
|
||||
tx: &impl DbTxMut<'db>,
|
||||
block: BlockNumber,
|
||||
) -> Result<(), DbError> {
|
||||
counter!("stage.progress", block, "stage" => self.0);
|
||||
tx.put::<SyncStage>(self.0.as_bytes().to_vec(), block)
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,12 @@
|
||||
//! Staged syncing primitives for reth.
|
||||
//!
|
||||
//! See [Stage] and [Pipeline].
|
||||
//!
|
||||
//! # Metrics
|
||||
//!
|
||||
//! This library exposes metrics via. the [`metrics`][metrics] crate:
|
||||
//!
|
||||
//! - `stage.progress{stage}`: The block number each stage has currently reached.
|
||||
|
||||
mod error;
|
||||
mod id;
|
||||
@ -18,3 +24,7 @@ pub use error::*;
|
||||
pub use id::*;
|
||||
pub use pipeline::*;
|
||||
pub use stage::*;
|
||||
|
||||
// NOTE: Needed so the link in the module-level rustdoc works.
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate metrics;
|
||||
|
||||
Reference in New Issue
Block a user