use super::*;
#[derive(Debug, Default)]
pub struct Counter {
pub(crate) value: AtomicU64,
}
#[derive(Debug, Default)]
pub struct Gauge {
pub(crate) value: AtomicI64,
}
#[derive(Debug)]
pub struct Histogram {
pub(crate) bounds: Vec<f64>,
pub(crate) bucket_counts: Vec<AtomicU64>,
pub(crate) total_count: AtomicU64,
pub(crate) sum_bits: AtomicU64,
}
pub(crate) struct RegisteredCounter {
pub(crate) help: String,
pub(crate) metric: Arc<Counter>,
}
pub(crate) struct RegisteredGauge {
pub(crate) help: String,
pub(crate) metric: Arc<Gauge>,
}
pub(crate) struct RegisteredHistogram {
pub(crate) help: String,
pub(crate) metric: Arc<Histogram>,
}
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct MetricsConfig {
pub(crate) endpoint: String,
pub(crate) namespace: String,
#[get(type(clone))]
pub(crate) bearer_token: Option<String>,
}
pub(crate) struct MetricsRegistryInner {
pub(crate) namespace: String,
pub(crate) status_class_counts: [Counter; 6],
pub(crate) in_flight: Gauge,
pub(crate) response_bytes_total: Counter,
pub(crate) duration_seconds: Histogram,
pub(crate) custom_counters: RwLock<HashMapXxHash3_64<String, RegisteredCounter>>,
pub(crate) custom_gauges: RwLock<HashMapXxHash3_64<String, RegisteredGauge>>,
pub(crate) custom_histograms: RwLock<HashMapXxHash3_64<String, RegisteredHistogram>>,
}
#[derive(Clone)]
pub struct MetricsRegistry {
pub(crate) inner: Arc<MetricsRegistryInner>,
}
#[derive(Clone)]
pub struct MetricsPlugin {
pub(crate) config: MetricsConfig,
pub(crate) registry: MetricsRegistry,
}
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::request_middleware(-115)]
pub struct MetricsRequestHook;
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::response_middleware(95)]
pub struct MetricsResponseHook;