use crate::authenticated::discovery::metrics;
use commonware_cryptography::PublicKey;
use commonware_runtime::{
telemetry::metrics::{CounterFamily, Gauge, GaugeFamily, MetricsExt as _},
Metrics as RuntimeMetrics,
};
pub struct Metrics<P: PublicKey> {
pub tracked: Gauge,
pub blocked: GaugeFamily<metrics::Peer<P>>,
pub reserved: Gauge,
pub connected: GaugeFamily<metrics::Peer<P>>,
pub limits: CounterFamily<metrics::Peer<P>>,
pub updates: CounterFamily<metrics::Peer<P>>,
}
impl<P: PublicKey> Metrics<P> {
pub fn init<E: RuntimeMetrics>(context: &E) -> Self {
Self {
tracked: context.gauge(
"tracked",
"Total number of unique peers in all peer sets being tracked",
),
blocked: context.family(
"blocked",
"Blocked peers (value = expiry time as epoch millis)",
),
reserved: context.gauge("reserved", "Total number of outstanding reservations"),
connected: context.family(
"connected",
"Unix timestamp in milliseconds when each connected peer became active",
),
limits: context.family(
"limits",
"Count of the number of rate-limited reservation events for each peer",
),
updates: context.family("updates", "Count of the number of updates for each peer"),
}
}
}