@@ -1236,12 +1236,12 @@ mod tests {
12361236 assert_eq ! ( mfs. len( ) , 1 ) ;
12371237
12381238 let mf = mfs. pop ( ) . unwrap ( ) ;
1239- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1240- assert_eq ! ( m. get_label ( ) . len( ) , 2 ) ;
1241- let proto_histogram = m. get_histogram ( ) ;
1242- assert_eq ! ( proto_histogram. get_sample_count ( ) , 3 ) ;
1243- assert ! ( proto_histogram. get_sample_sum ( ) >= 1.5 ) ;
1244- assert_eq ! ( proto_histogram. get_bucket ( ) . len( ) , DEFAULT_BUCKETS . len( ) ) ;
1239+ let m = mf. metric . get ( 0 ) . unwrap ( ) ;
1240+ assert_eq ! ( m. label . len( ) , 2 ) ;
1241+ let proto_histogram = m. histogram . as_ref ( ) . unwrap ( ) ;
1242+ assert_eq ! ( proto_histogram. sample_count . unwrap_or ( 0 ) , 3 ) ;
1243+ assert ! ( proto_histogram. sample_sum . unwrap_or ( 0.0 ) >= 1.5 ) ;
1244+ assert_eq ! ( proto_histogram. bucket . len( ) , DEFAULT_BUCKETS . len( ) ) ;
12451245
12461246 let buckets = vec ! [ 1.0 , 2.0 , 3.0 ] ;
12471247 let opts = HistogramOpts :: new ( "test2" , "test help" ) . buckets ( buckets. clone ( ) ) ;
@@ -1250,12 +1250,12 @@ mod tests {
12501250 assert_eq ! ( mfs. len( ) , 1 ) ;
12511251
12521252 let mf = mfs. pop ( ) . unwrap ( ) ;
1253- let m = mf. get_metric ( ) . get ( 0 ) . unwrap ( ) ;
1254- assert_eq ! ( m. get_label ( ) . len( ) , 0 ) ;
1255- let proto_histogram = m. get_histogram ( ) ;
1256- assert_eq ! ( proto_histogram. get_sample_count ( ) , 0 ) ;
1257- assert ! ( ( proto_histogram. get_sample_sum ( ) - 0.0 ) < EPSILON ) ;
1258- assert_eq ! ( proto_histogram. get_bucket ( ) . len( ) , buckets. len( ) )
1253+ let m = mf. metric . get ( 0 ) . unwrap ( ) ;
1254+ assert_eq ! ( m. label . len( ) , 0 ) ;
1255+ let proto_histogram = m. histogram . as_ref ( ) . unwrap ( ) ;
1256+ assert_eq ! ( proto_histogram. sample_count . unwrap_or ( 0 ) , 0 ) ;
1257+ assert ! ( ( proto_histogram. sample_sum . unwrap_or ( 0.0 ) - 0.0 ) < EPSILON ) ;
1258+ assert_eq ! ( proto_histogram. bucket . len( ) , buckets. len( ) )
12591259 }
12601260
12611261 #[ test]
@@ -1400,12 +1400,12 @@ mod tests {
14001400 histogram. observe ( 1.0 ) ;
14011401
14021402 let m = histogram. metric ( ) ;
1403- assert_eq ! ( m. get_label ( ) . len( ) , labels. len( ) ) ;
1403+ assert_eq ! ( m. label . len( ) , labels. len( ) ) ;
14041404
1405- let proto_histogram = m. get_histogram ( ) ;
1406- assert_eq ! ( proto_histogram. get_sample_count ( ) , 1 ) ;
1407- assert ! ( ( proto_histogram. get_sample_sum ( ) - 1.0 ) < EPSILON ) ;
1408- assert_eq ! ( proto_histogram. get_bucket ( ) . len( ) , buckets. len( ) )
1405+ let proto_histogram = m. histogram . unwrap ( ) ;
1406+ assert_eq ! ( proto_histogram. sample_count . unwrap_or ( 0 ) , 1 ) ;
1407+ assert ! ( ( proto_histogram. sample_sum . unwrap_or ( 0.0 ) - 1.0 ) < EPSILON ) ;
1408+ assert_eq ! ( proto_histogram. bucket . len( ) , buckets. len( ) )
14091409 }
14101410
14111411 #[ test]
@@ -1418,9 +1418,9 @@ mod tests {
14181418
14191419 let check = |count, sum| {
14201420 let m = histogram. metric ( ) ;
1421- let proto_histogram = m. get_histogram ( ) ;
1422- assert_eq ! ( proto_histogram. get_sample_count ( ) , count) ;
1423- assert ! ( ( proto_histogram. get_sample_sum ( ) - sum) < EPSILON ) ;
1421+ let proto_histogram = m. histogram . unwrap ( ) ;
1422+ assert_eq ! ( proto_histogram. sample_count . unwrap_or ( 0 ) , count) ;
1423+ assert ! ( ( proto_histogram. sample_sum . unwrap_or ( 0.0 ) - sum) < EPSILON ) ;
14241424 } ;
14251425
14261426 local. observe ( 1.0 ) ;
@@ -1452,10 +1452,10 @@ mod tests {
14521452 local_vec. remove_label_values ( & [ "v1" , "v2" ] ) . unwrap_err ( ) ;
14531453
14541454 let check = |count, sum| {
1455- let ms = vec. collect ( ) [ 0 ] . take_metric ( ) ;
1456- let proto_histogram = ms[ 0 ] . get_histogram ( ) ;
1457- assert_eq ! ( proto_histogram. get_sample_count ( ) , count) ;
1458- assert ! ( ( proto_histogram. get_sample_sum ( ) - sum) < EPSILON ) ;
1455+ let ms = & vec. collect ( ) [ 0 ] . metric ;
1456+ let proto_histogram = & ms[ 0 ] . histogram . as_ref ( ) . unwrap ( ) ;
1457+ assert_eq ! ( proto_histogram. sample_count . unwrap_or ( 0 ) , count) ;
1458+ assert ! ( ( proto_histogram. sample_sum . unwrap_or ( 0.0 ) - sum) < EPSILON ) ;
14591459 } ;
14601460
14611461 {
@@ -1509,13 +1509,13 @@ mod tests {
15091509 let mut cumulative_count = 0 ;
15101510 let mut sample_sum = 0 ;
15111511 for _ in 0 ..1_000_000 {
1512- let metric = & histogram. collect ( ) [ 0 ] . take_metric ( ) [ 0 ] ;
1513- let proto = metric. get_histogram ( ) ;
1512+ let metric = & histogram. collect ( ) [ 0 ] . metric [ 0 ] ;
1513+ let proto = metric. histogram . as_ref ( ) . unwrap ( ) ;
15141514
1515- sample_count = proto. get_sample_count ( ) ;
1516- sample_sum = proto. get_sample_sum ( ) as u64 ;
1515+ sample_count = proto. sample_count . unwrap_or ( 0 ) ;
1516+ sample_sum = proto. sample_sum . unwrap_or ( 0.0 ) as u64 ;
15171517 // There is only one bucket thus the `[0]`.
1518- cumulative_count = proto. get_bucket ( ) [ 0 ] . get_cumulative_count ( ) ;
1518+ cumulative_count = proto. bucket [ 0 ] . cumulative_count . unwrap_or ( 0 ) ;
15191519
15201520 if sample_count != cumulative_count {
15211521 break ;
0 commit comments