#[allow(dead_code)]
use std::collections::HashMap;
use std::io;
use crate::metrics::prometheus_exporter::distribution::Distribution;
use metrics::SetRecorderError;
use thiserror::Error as ThisError;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[allow(dead_code)]
pub enum Matcher {
Full(String),
Prefix(String),
Suffix(String),
}
impl Matcher {
pub fn matches(&self, key: &str) -> bool {
match self {
Matcher::Prefix(prefix) => key.starts_with(prefix),
Matcher::Suffix(suffix) => key.ends_with(suffix),
Matcher::Full(full) => key == full,
}
}
}
#[derive(Debug, ThisError)]
pub enum InstallError {
#[error("failed to spawn Tokio runtime for endpoint: {0}")]
Io(#[from] io::Error),
#[error("failed to bind to given listen address: {0}")]
Hyper(#[from] hyper::Error),
#[error("failed to install exporter as global recorder: {0}")]
Recorder(#[from] SetRecorderError),
}
pub struct Snapshot {
pub counters: HashMap<String, HashMap<Vec<String>, u64>>,
pub gauges: HashMap<String, HashMap<Vec<String>, f64>>,
pub distributions: HashMap<String, HashMap<Vec<String>, Distribution>>,
}