@@ -284,11 +284,11 @@ impl ShardAndCount {
284
284
/// A histogram supports two main execution paths:
285
285
///
286
286
/// 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.
288
288
///
289
289
/// 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.
292
292
///
293
293
/// If an observe and a collect operation interleave, the latter could be
294
294
/// exposing a snapshot of the histogram that does not uphold all histogram
@@ -1207,7 +1207,7 @@ impl Clone for LocalHistogramVec {
1207
1207
1208
1208
#[ cfg( test) ]
1209
1209
mod tests {
1210
- use std:: f64:: { EPSILON , INFINITY } ;
1210
+ use std:: f64;
1211
1211
use std:: thread;
1212
1212
use std:: time:: Duration ;
1213
1213
@@ -1237,7 +1237,7 @@ mod tests {
1237
1237
assert_eq ! ( mfs. len( ) , 1 ) ;
1238
1238
1239
1239
let mf = mfs. pop ( ) . unwrap ( ) ;
1240
- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1240
+ let m = mf. get_metric ( ) . first ( ) . unwrap ( ) ;
1241
1241
assert_eq ! ( m. get_label( ) . len( ) , 2 ) ;
1242
1242
let proto_histogram = m. get_histogram ( ) ;
1243
1243
assert_eq ! ( proto_histogram. get_sample_count( ) , 3 ) ;
@@ -1251,11 +1251,11 @@ mod tests {
1251
1251
assert_eq ! ( mfs. len( ) , 1 ) ;
1252
1252
1253
1253
let mf = mfs. pop ( ) . unwrap ( ) ;
1254
- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1254
+ let m = mf. get_metric ( ) . first ( ) . unwrap ( ) ;
1255
1255
assert_eq ! ( m. get_label( ) . len( ) , 0 ) ;
1256
1256
let proto_histogram = m. get_histogram ( ) ;
1257
1257
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 ) ;
1259
1259
assert_eq ! ( proto_histogram. get_bucket( ) . len( ) , buckets. len( ) )
1260
1260
}
1261
1261
@@ -1287,7 +1287,7 @@ mod tests {
1287
1287
let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1288
1288
let proto_histogram = m. get_histogram ( ) ;
1289
1289
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 ) ;
1291
1291
}
1292
1292
1293
1293
#[ test]
@@ -1311,7 +1311,11 @@ mod tests {
1311
1311
( vec![ ] , true , DEFAULT_BUCKETS . len( ) ) ,
1312
1312
( vec![ -2.0 , -1.0 , -0.5 , 0.0 , 0.5 , 1.0 , 2.0 ] , true , 7 ) ,
1313
1313
( 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
+ ) ,
1315
1319
] ;
1316
1320
1317
1321
for ( buckets, is_ok, length) in table {
@@ -1366,7 +1370,7 @@ mod tests {
1366
1370
for ( millis, seconds) in tbls {
1367
1371
let d = Duration :: from_millis ( millis) ;
1368
1372
let v = duration_to_seconds ( d) ;
1369
- assert ! ( ( v - seconds) . abs( ) < EPSILON ) ;
1373
+ assert ! ( ( v - seconds) . abs( ) < f64 :: EPSILON ) ;
1370
1374
}
1371
1375
}
1372
1376
@@ -1405,7 +1409,7 @@ mod tests {
1405
1409
1406
1410
let proto_histogram = m. get_histogram ( ) ;
1407
1411
assert_eq ! ( proto_histogram. get_sample_count( ) , 1 ) ;
1408
- assert ! ( ( proto_histogram. get_sample_sum( ) - 1.0 ) < EPSILON ) ;
1412
+ assert ! ( ( proto_histogram. get_sample_sum( ) - 1.0 ) < f64 :: EPSILON ) ;
1409
1413
assert_eq ! ( proto_histogram. get_bucket( ) . len( ) , buckets. len( ) )
1410
1414
}
1411
1415
@@ -1421,7 +1425,7 @@ mod tests {
1421
1425
let m = histogram. metric ( ) ;
1422
1426
let proto_histogram = m. get_histogram ( ) ;
1423
1427
assert_eq ! ( proto_histogram. get_sample_count( ) , count) ;
1424
- assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < EPSILON ) ;
1428
+ assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < f64 :: EPSILON ) ;
1425
1429
} ;
1426
1430
1427
1431
local. observe ( 1.0 ) ;
@@ -1456,7 +1460,7 @@ mod tests {
1456
1460
let ms = vec. collect ( ) [ 0 ] . take_metric ( ) ;
1457
1461
let proto_histogram = ms[ 0 ] . get_histogram ( ) ;
1458
1462
assert_eq ! ( proto_histogram. get_sample_count( ) , count) ;
1459
- assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < EPSILON ) ;
1463
+ assert ! ( ( proto_histogram. get_sample_sum( ) - sum) < f64 :: EPSILON ) ;
1460
1464
} ;
1461
1465
1462
1466
{
0 commit comments