1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use std::collections::HashMap;
use std::io;
use crate::distribution::Distribution;
use metrics::SetRecorderError;
use thiserror::Error as ThisError;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
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),
#[cfg(feature = "tokio-exporter")]
#[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>>,
}