wip: mixnet metrics
This commit is contained in:
parent
a9bdab28d3
commit
d2c6520a7b
|
@ -22,6 +22,7 @@ futures = "0.3"
|
|||
parking_lot = "0.12"
|
||||
nomos-core = { path = "../../nomos-core" }
|
||||
nomos-libp2p = { path = "../../nomos-libp2p", optional = true }
|
||||
nomos-metrics = { path = "../metrics", optional = true }
|
||||
mixnet = { path = "../../mixnet", optional = true }
|
||||
|
||||
utoipa = { version = "4.0", optional = true }
|
||||
|
@ -36,3 +37,4 @@ libp2p = ["nomos-libp2p", "rand", "humantime-serde"]
|
|||
mixnet = ["dep:mixnet"]
|
||||
mock = ["rand", "chrono"]
|
||||
openapi = ["dep:utoipa", "serde_json"]
|
||||
metrics = ["nomos-metrics"]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
pub mod backends;
|
||||
#[cfg(feature = "metrics")]
|
||||
pub mod metrics;
|
||||
// std
|
||||
use std::fmt::{self, Debug};
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
use nomos_metrics::{metrics::gauge::Gauge, NomosRegistry};
|
||||
use overwatch_rs::services::ServiceId;
|
||||
|
||||
pub(crate) struct Metrics {
|
||||
mixing_packets: Gauge,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
pub(crate) fn new(registry: NomosRegistry, discriminant: ServiceId) -> Self {
|
||||
let mut registry = registry
|
||||
.lock()
|
||||
.expect("should've acquired the lock for registry");
|
||||
let sub_registry = registry.sub_registry_with_prefix(discriminant);
|
||||
|
||||
let mixing_packets = Gauge::default();
|
||||
sub_registry.register(
|
||||
"mixing_packets",
|
||||
"Number of packets being mixed in the mixnode",
|
||||
mixing_packets.clone(),
|
||||
);
|
||||
|
||||
Self { mixing_packets }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue