@@ -123,6 +123,7 @@ mod tests {
123123 use data:: GaugeDataPoint ;
124124 use opentelemetry:: metrics:: { Counter , Meter , UpDownCounter } ;
125125 use opentelemetry:: InstrumentationScope ;
126+ use opentelemetry:: Value ;
126127 use opentelemetry:: { metrics:: MeterProvider as _, KeyValue } ;
127128 use rand:: { rngs, Rng , SeedableRng } ;
128129 use std:: cmp:: { max, min} ;
@@ -2400,8 +2401,7 @@ mod tests {
24002401 assert_eq ! ( sum. data_points. len( ) , 2002 ) ;
24012402
24022403 let data_point =
2403- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2404- . expect ( "overflow point expected" ) ;
2404+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
24052405 assert_eq ! ( data_point. value, 300 ) ;
24062406
24072407 // let empty_attrs_data_point = &sum.data_points[0];
@@ -2449,8 +2449,7 @@ mod tests {
24492449 // For cumulative, overflow should still be there, and new points should not be added.
24502450 assert_eq ! ( sum. data_points. len( ) , 2002 ) ;
24512451 let data_point =
2452- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2453- . expect ( "overflow point expected" ) ;
2452+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
24542453 assert_eq ! ( data_point. value, 600 ) ;
24552454
24562455 let data_point = find_sum_datapoint_with_key_value ( & sum. data_points , "A" , "foo" ) ;
@@ -2506,8 +2505,7 @@ mod tests {
25062505 assert_eq ! ( sum. data_points. len( ) , cardinality_limit + 1 + 1 ) ;
25072506
25082507 let data_point =
2509- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2510- . expect ( "overflow point expected" ) ;
2508+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
25112509 assert_eq ! ( data_point. value, 300 ) ;
25122510
25132511 // let empty_attrs_data_point = &sum.data_points[0];
@@ -2555,8 +2553,7 @@ mod tests {
25552553 // For cumulative, overflow should still be there, and new points should not be added.
25562554 assert_eq ! ( sum. data_points. len( ) , cardinality_limit + 1 + 1 ) ;
25572555 let data_point =
2558- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2559- . expect ( "overflow point expected" ) ;
2556+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
25602557 assert_eq ! ( data_point. value, 600 ) ;
25612558
25622559 let data_point = find_sum_datapoint_with_key_value ( & sum. data_points , "A" , "foo" ) ;
@@ -2605,8 +2602,7 @@ mod tests {
26052602 assert_eq ! ( sum. data_points. len( ) , cardinality_limit + 1 + 1 ) ;
26062603
26072604 let data_point =
2608- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2609- . expect ( "overflow point expected" ) ;
2605+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
26102606 assert_eq ! ( data_point. value, 300 ) ;
26112607
26122608 // let empty_attrs_data_point = &sum.data_points[0];
@@ -2654,8 +2650,7 @@ mod tests {
26542650 // For cumulative, overflow should still be there, and new points should not be added.
26552651 assert_eq ! ( sum. data_points. len( ) , cardinality_limit + 1 + 1 ) ;
26562652 let data_point =
2657- find_sum_datapoint_with_key_value ( & sum. data_points , "otel.metric.overflow" , "true" )
2658- . expect ( "overflow point expected" ) ;
2653+ find_overflow_sum_datapoint ( & sum. data_points ) . expect ( "overflow point expected" ) ;
26592654 assert_eq ! ( data_point. value, 600 ) ;
26602655
26612656 let data_point = find_sum_datapoint_with_key_value ( & sum. data_points , "A" , "foo" ) ;
@@ -2838,6 +2833,14 @@ mod tests {
28382833 } )
28392834 }
28402835
2836+ fn find_overflow_sum_datapoint < T > ( data_points : & [ SumDataPoint < T > ] ) -> Option < & SumDataPoint < T > > {
2837+ data_points. iter ( ) . find ( |& datapoint| {
2838+ datapoint. attributes . iter ( ) . any ( |kv| {
2839+ kv. key . as_str ( ) == "otel.metric.overflow" && kv. value == Value :: Bool ( true )
2840+ } )
2841+ } )
2842+ }
2843+
28412844 fn find_gauge_datapoint_with_key_value < ' a , T > (
28422845 data_points : & ' a [ GaugeDataPoint < T > ] ,
28432846 key : & str ,
0 commit comments