s2_common/types/
metrics.rs1use compact_str::CompactString;
2
3#[derive(Clone, Copy, Debug)]
4pub enum MetricUnit {
5 Bytes,
6 Operations,
7}
8
9#[derive(Clone, Copy, Debug, strum::IntoStaticStr)]
10pub enum TimeseriesInterval {
11 #[strum(serialize = "minute")]
12 Minute,
13 #[strum(serialize = "hour")]
14 Hour,
15 #[strum(serialize = "day")]
16 Day,
17}
18
19#[derive(Debug, Clone)]
20pub struct ScalarMetric {
21 pub name: CompactString,
22 pub unit: MetricUnit,
23 pub value: f64,
24}
25
26#[derive(Debug, Clone)]
27pub struct AccumulationMetric {
28 pub name: CompactString,
29 pub unit: MetricUnit,
30 pub interval: TimeseriesInterval,
31 pub values: Vec<(u32, f64)>,
32}
33
34#[derive(Debug, Clone)]
35pub struct GaugeMetric {
36 pub name: CompactString,
37 pub unit: MetricUnit,
38 pub values: Vec<(u32, f64)>,
39}
40
41#[derive(Debug, Clone)]
42pub struct LabelMetric {
43 pub name: CompactString,
44 pub values: Vec<String>,
45}
46
47#[derive(Debug, Clone)]
48pub enum Metric {
49 Scalar(ScalarMetric),
50 Accumulation(AccumulationMetric),
51 Gauge(GaugeMetric),
52 Label(LabelMetric),
53}
54
55pub enum AccountMetricSet {
56 ActiveBasins,
57 AccountOps,
58}
59
60pub struct AccountMetricsRequest {
61 pub set: AccountMetricSet,
62 pub start: Option<u32>,
63 pub end: Option<u32>,
64 pub interval: Option<TimeseriesInterval>,
65}
66
67pub enum BasinMetricSet {
68 Storage,
69 AppendOps,
70 BasinOps,
71 ReadOps,
72 ReadThroughput,
73 AppendThroughput,
74}
75
76pub struct BasinMetricsRequest {
77 pub set: BasinMetricSet,
78 pub start: Option<u32>,
79 pub end: Option<u32>,
80 pub interval: Option<TimeseriesInterval>,
81}
82
83pub enum StreamMetricSet {
84 Storage,
85}
86
87pub struct StreamMetricsRequest {
88 pub set: StreamMetricSet,
89 pub start: Option<u32>,
90 pub end: Option<u32>,
91 pub interval: Option<TimeseriesInterval>,
92}
93
94pub struct MetricsResponse {
96 pub values: Vec<Metric>,
97}