use commonware_runtime::telemetry::metrics::{Batched, Counter, Gauge, GaugeValue, raw};
pub trait GaugeHandle: Send + Sync {
fn inc(&mut self);
fn dec(&mut self);
fn dec_by(&mut self, value: GaugeValue);
fn get(&self) -> GaugeValue;
}
pub trait CounterHandle: Send + Sync {
fn inc(&mut self);
fn inc_by(&mut self, value: u64);
fn get(&self) -> u64;
}
impl GaugeHandle for Gauge {
fn inc(&mut self) {
self.metric().inc();
}
fn dec(&mut self) {
self.metric().dec();
}
fn dec_by(&mut self, value: GaugeValue) {
self.metric().dec_by(value);
}
fn get(&self) -> GaugeValue {
self.metric().get()
}
}
impl CounterHandle for Counter {
fn inc(&mut self) {
self.metric().inc();
}
fn inc_by(&mut self, value: u64) {
self.metric().inc_by(value);
}
fn get(&self) -> u64 {
self.metric().get()
}
}
impl GaugeHandle for Batched<raw::Gauge> {
fn inc(&mut self) {
Self::inc(self);
}
fn dec(&mut self) {
Self::dec(self);
}
fn dec_by(&mut self, value: GaugeValue) {
Self::dec_by(self, value);
}
fn get(&self) -> GaugeValue {
Self::get(self)
}
}
impl CounterHandle for Batched<raw::Counter> {
fn inc(&mut self) {
Self::inc(self);
}
fn inc_by(&mut self, value: u64) {
Self::inc_by(self, value);
}
fn get(&self) -> u64 {
Self::get(self)
}
}