|
1 | 1 | use std::sync::Arc; |
2 | 2 |
|
3 | | -use prometheus_client::encoding::text::encode; |
4 | | -use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue}; |
5 | | -use prometheus_client::metrics::counter::Counter; |
6 | | -use prometheus_client::metrics::family::Family; |
7 | | -use prometheus_client::registry::Registry; |
| 3 | +use prometheus_client::{ |
| 4 | + encoding::{EncodeLabelSet, EncodeLabelValue, text::encode}, |
| 5 | + metrics::{counter::Counter, family::Family}, |
| 6 | + registry::Registry, |
| 7 | +}; |
8 | 8 |
|
9 | | -#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug)] |
| 9 | +#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug, PartialOrd, Ord)] |
10 | 10 | struct Labels { |
11 | 11 | method: Method, |
12 | 12 | path: String, |
13 | 13 | } |
14 | 14 |
|
15 | | -#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug)] |
| 15 | +#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug, PartialOrd, Ord)] |
16 | 16 | enum Method { |
17 | 17 | Get, |
18 | 18 | #[allow(dead_code)] |
@@ -47,11 +47,11 @@ fn basic_flow() { |
47 | 47 |
|
48 | 48 | mod protobuf { |
49 | 49 | use crate::{Labels, Method}; |
50 | | - use prometheus_client::encoding::prometheus_protobuf::encode; |
51 | | - use prometheus_client::encoding::prometheus_protobuf::prometheus_data_model; |
52 | | - use prometheus_client::metrics::counter::Counter; |
53 | | - use prometheus_client::metrics::family::Family; |
54 | | - use prometheus_client::registry::Registry; |
| 50 | + use prometheus_client::{ |
| 51 | + encoding::prometheus_protobuf::{encode, prometheus_data_model}, |
| 52 | + metrics::{counter::Counter, family::Family}, |
| 53 | + registry::Registry, |
| 54 | + }; |
55 | 55 |
|
56 | 56 | #[test] |
57 | 57 | fn structs() { |
@@ -106,7 +106,7 @@ mod protobuf { |
106 | 106 |
|
107 | 107 | #[test] |
108 | 108 | fn remap_keyword_identifiers() { |
109 | | - #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] |
| 109 | + #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug, PartialOrd, Ord)] |
110 | 110 | struct Labels { |
111 | 111 | // `r#type` is problematic as `r#` is not a valid OpenMetrics label name |
112 | 112 | // but one needs to use keyword identifier syntax (aka. raw identifiers) |
@@ -137,7 +137,7 @@ fn remap_keyword_identifiers() { |
137 | 137 |
|
138 | 138 | #[test] |
139 | 139 | fn arc_string() { |
140 | | - #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] |
| 140 | + #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug, PartialOrd, Ord)] |
141 | 141 | struct Labels { |
142 | 142 | client_id: Arc<String>, |
143 | 143 | } |
@@ -167,12 +167,12 @@ fn arc_string() { |
167 | 167 |
|
168 | 168 | #[test] |
169 | 169 | fn flatten() { |
170 | | - #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] |
| 170 | + #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug, PartialOrd, Ord)] |
171 | 171 | struct CommonLabels { |
172 | 172 | a: u64, |
173 | 173 | b: u64, |
174 | 174 | } |
175 | | - #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)] |
| 175 | + #[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug, PartialOrd, Ord)] |
176 | 176 | struct Labels { |
177 | 177 | unique: u64, |
178 | 178 | #[prometheus(flatten)] |
|
0 commit comments