Skip to content

Commit

Permalink
Metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Jan 29, 2025
1 parent 0fbd61c commit b1abfa0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use {
crate::{database::Postgres, domain::eth, infra::Ethereum},
crate::{
database::Postgres,
domain::{eth, Metrics},
infra::Ethereum,
},
ethrpc::block_stream::CurrentBlockWatcher,
std::{
sync::Arc,
Expand Down Expand Up @@ -117,7 +121,15 @@ impl DatabaseSolverParticipationValidator {
Ok(non_settling_solvers) => {
let non_settling_solvers = non_settling_solvers
.into_iter()
.map(|solver| eth::Address(solver.0.into()))
.map(|solver| {
let address = eth::Address(solver.0.into());

Metrics::get()
.non_settling_solver
.with_label_values(&[&format!("{:#x}", address.0)]);

address
})
.collect::<Vec<_>>();

tracing::debug!(?non_settling_solvers, "found non-settling solvers");
Expand Down
15 changes: 15 additions & 0 deletions crates/autopilot/src/domain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ pub use {
fee::ProtocolFees,
quote::Quote,
};

#[derive(prometheus_metric_storage::MetricStorage)]
#[metric(subsystem = "domain")]
pub struct Metrics {
/// How many times the solver marked as non-settling based on the database
/// statistics.
#[metric(labels("solver"))]
pub non_settling_solver: prometheus::IntCounterVec,
}

impl Metrics {
fn get() -> &'static Self {
Metrics::instance(observe::metrics::get_storage_registry()).unwrap()
}
}

0 comments on commit b1abfa0

Please sign in to comment.