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 1919use std:: collections:: HashMap ;
2020use std:: sync:: Arc ;
2121
22- use itertools:: Itertools ;
2322use prometheus:: core:: Collector ;
2423use prometheus:: proto:: MetricFamily ;
2524use prometheus:: IntGaugeVec ;
@@ -199,16 +198,12 @@ fn delete_with_label_prefix(metrics: &IntGaugeVec, prefix: &[&str]) {
199198 . map ( |l| ( l. get_name ( ) , l. get_value ( ) ) )
200199 . collect ( ) ;
201200
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 {
210205 if let Err ( err) = metrics. remove ( & label_map) {
211- warn ! ( "Error = { err}" ) ;
206+ warn ! ( "Error removing metric with labels {:?}: { err}" , label_map ) ;
212207 }
213208 }
214209 }
You can’t perform that action at this time.
0 commit comments