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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use data::Meters;
use std::sync::mpsc::SyncSender;
pub const SECOND: u64 = 1_000_000_000;
pub const MINUTE: u64 = 60 * SECOND;
#[derive(Clone, Eq, Hash, PartialEq)]
pub enum Interest<T> {
AllanDeviation(T),
Count(T),
Gauge(T),
LatencyPercentile(T),
ValuePercentile(T),
LatencyTrace(T, String),
LatencyWaterfall(T, String),
ValueTrace(T, String),
ValueWaterfall(T, String),
}
#[derive(Clone)]
pub enum ControlMessage<T> {
AddInterest(Interest<T>),
RemoveInterest(Interest<T>),
SnapshotMeters(SyncSender<Meters<T>>),
}
#[derive(Clone)]
pub struct Percentile(pub String, pub f64);
pub fn default_percentiles() -> Vec<Percentile> {
let mut p = Vec::new();
p.push(Percentile("min".to_owned(), 0.0));
p.push(Percentile("p50".to_owned(), 50.0));
p.push(Percentile("p75".to_owned(), 75.0));
p.push(Percentile("p90".to_owned(), 90.0));
p.push(Percentile("p95".to_owned(), 95.0));
p.push(Percentile("p99".to_owned(), 99.0));
p.push(Percentile("p999".to_owned(), 99.9));
p.push(Percentile("p9999".to_owned(), 99.99));
p.push(Percentile("max".to_owned(), 100.0));
p
}
pub fn default_taus() -> Vec<usize> {
let mut t = Vec::new();
for i in 1..301 {
t.push(i);
}
t
}
#[allow(dead_code)]
pub fn is_between(value: f64, min: f64, max: f64) -> bool {
value >= min && value <= max
}