feat: metrics (#92)

* feat(stages): `stage.progress` metric

* docs: metrics
This commit is contained in:
Bjerg
2022-10-24 15:16:45 +02:00
committed by GitHub
parent 8bc8bd6820
commit 65247ef203
9 changed files with 121 additions and 2 deletions

View File

@ -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"] }

View File

@ -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)
}
}

View File

@ -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;