File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 19
19
use std:: collections:: HashMap ;
20
20
use std:: sync:: Arc ;
21
21
22
- use itertools:: Itertools ;
23
22
use prometheus:: core:: Collector ;
24
23
use prometheus:: proto:: MetricFamily ;
25
24
use prometheus:: IntGaugeVec ;
@@ -199,16 +198,12 @@ fn delete_with_label_prefix(metrics: &IntGaugeVec, prefix: &[&str]) {
199
198
. map ( |l| ( l. get_name ( ) , l. get_value ( ) ) )
200
199
. collect ( ) ;
201
200
202
- let mut should_continue = false ;
203
- prefix. iter ( ) . for_each ( |p| {
204
- // label map doesn't have the key present in prefix, hence continue
205
- if !label_map. values ( ) . contains ( p) {
206
- should_continue = true ;
207
- }
208
- } ) ;
209
- if !should_continue {
201
+ // Check if all prefix elements are present in label values
202
+ let all_prefixes_found = prefix. iter ( ) . all ( |p| label_map. values ( ) . any ( |v| v == p) ) ;
203
+
204
+ if all_prefixes_found {
210
205
if let Err ( err) = metrics. remove ( & label_map) {
211
- warn ! ( "Error = { err}" ) ;
206
+ warn ! ( "Error removing metric with labels {:?}: { err}" , label_map ) ;
212
207
}
213
208
}
214
209
}
You can’t perform that action at this time.
0 commit comments