@@ -284,11 +284,11 @@ impl ShardAndCount {
284284/// A histogram supports two main execution paths:
285285///
286286/// 1. `observe` which increases the overall observation counter, updates the
287- /// observation sum and increases a single bucket counter.
287+ /// observation sum and increases a single bucket counter.
288288///
289289/// 2. `proto` (aka. collecting the metric, from now on referred to as the
290- /// collect operation) which snapshots the state of the histogram and exposes it
291- /// as a Protobuf struct.
290+ /// collect operation) which snapshots the state of the histogram and exposes
291+ /// it as a Protobuf struct.
292292///
293293/// If an observe and a collect operation interleave, the latter could be
294294/// exposing a snapshot of the histogram that does not uphold all histogram
@@ -1207,7 +1207,7 @@ impl Clone for LocalHistogramVec {
12071207
12081208#[ cfg( test) ]
12091209mod tests {
1210- use std:: f64:: { EPSILON , INFINITY } ;
1210+ use std:: f64;
12111211 use std:: thread;
12121212 use std:: time:: Duration ;
12131213
@@ -1237,7 +1237,7 @@ mod tests {
12371237 assert_eq ! ( mfs. len( ) , 1 ) ;
12381238
12391239 let mf = mfs. pop ( ) . unwrap ( ) ;
1240- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1240+ let m = mf. get_metric ( ) . first ( ) . unwrap ( ) ;
12411241 assert_eq ! ( m. get_label( ) . len( ) , 2 ) ;
12421242 let proto_histogram = m. get_histogram ( ) ;
12431243 assert_eq ! ( proto_histogram. get_sample_count( ) , 3 ) ;
@@ -1251,11 +1251,11 @@ mod tests {
12511251 assert_eq ! ( mfs. len( ) , 1 ) ;
12521252
12531253 let mf = mfs. pop ( ) . unwrap ( ) ;
1254- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1254+ let m = mf. get_metric ( ) . first ( ) . unwrap ( ) ;
12551255 assert_eq ! ( m. get_label( ) . len( ) , 0 ) ;
12561256 let proto_histogram = m. get_histogram ( ) ;
12571257 assert_eq ! ( proto_histogram. get_sample_count( ) , 0 ) ;
1258- assert ! ( ( proto_histogram. get_sample_sum( ) - 0.0 ) < EPSILON ) ;
1258+ assert ! ( ( proto_histogram. get_sample_sum( ) - 0.0 ) < f64 :: EPSILON ) ;
12591259 assert_eq ! ( proto_histogram. get_bucket( ) . len( ) , buckets. len( ) )
12601260 }
12611261
@@ -1287,7 +1287,7 @@ mod tests {
12871287 let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
12881288 let proto_histogram = m. get_histogram ( ) ;
12891289 assert_eq ! ( proto_histogram. get_sample_count( ) , 3 ) ;
1290- assert ! ( ( proto_histogram. get_sample_sum( ) - 0.0 ) > EPSILON ) ;
1290+ assert ! ( ( proto_histogram. get_sample_sum( ) - 0.0 ) > f64 :: EPSILON ) ;
12911291 }
12921292
12931293 #[ test]
@@ -1311,7 +1311,11 @@ mod tests {
13111311 ( vec![ ] , true , DEFAULT_BUCKETS . len( ) ) ,
13121312 ( vec![ -2.0 , -1.0 , -0.5 , 0.0 , 0.5 , 1.0 , 2.0 ] , true , 7 ) ,
13131313 ( vec![ -2.0 , -1.0 , -0.5 , 10.0 , 0.5 , 1.0 , 2.0 ] , false , 7 ) ,
1314- ( vec![ -2.0 , -1.0 , -0.5 , 0.0 , 0.5 , 1.0 , INFINITY ] , true , 6 ) ,
1314+ (
1315+ vec![ -2.0 , -1.0 , -0.5 , 0.0 , 0.5 , 1.0 , f64 :: INFINITY ] ,
1316+ true ,
1317+ 6 ,
1318+ ) ,
13151319 ] ;
13161320
13171321 for ( buckets, is_ok, length) in table {
@@ -1366,7 +1370,7 @@ mod tests {
13661370 for ( millis, seconds) in tbls {
13671371 let d = Duration :: from_millis ( millis) ;
13681372 let v = duration_to_seconds ( d) ;
1369- assert ! ( ( v - seconds) . abs( ) < EPSILON ) ;
1373+ assert ! ( ( v - seconds) . abs( ) < f64 :: EPSILON ) ;
13701374 }
13711375 }
13721376
@@ -1426,7 +1430,7 @@ mod tests {
14261430
14271431 let proto_histogram = m. get_histogram ( ) ;
14281432 assert_eq ! ( proto_histogram. get_sample_count( ) , 1 ) ;
1429- assert ! ( ( proto_histogram. get_sample_sum( ) - 1.0 ) < EPSILON ) ;
1433+ assert ! ( ( proto_histogram. get_sample_sum( ) - 1.0 ) < f64 :: EPSILON ) ;
14301434 assert_eq ! ( proto_histogram. get_bucket( ) . len( ) , buckets. len( ) )
14311435 }
14321436
@@ -1442,7 +1446,7 @@ mod tests {
14421446 let m = histogram. metric ( ) ;
14431447 let proto_histogram = m. get_histogram ( ) ;
14441448 assert_eq ! ( proto_histogram. get_sample_count( ) , count) ;
1445- assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < EPSILON ) ;
1449+ assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < f64 :: EPSILON ) ;
14461450 } ;
14471451
14481452 local. observe ( 1.0 ) ;
@@ -1477,7 +1481,7 @@ mod tests {
14771481 let ms = vec. collect ( ) [ 0 ] . take_metric ( ) ;
14781482 let proto_histogram = ms[ 0 ] . get_histogram ( ) ;
14791483 assert_eq ! ( proto_histogram. get_sample_count( ) , count) ;
1480- assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < EPSILON ) ;
1484+ assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < f64 :: EPSILON ) ;
14811485 } ;
14821486
14831487 {
0 commit comments