@@ -301,8 +301,12 @@ impl MetricsSet {
301301
302302 /// Sort the order of metrics so the "most useful" show up first
303303 pub fn sorted_for_display ( mut self ) -> Self {
304- self . metrics
305- . sort_unstable_by_key ( |metric| metric. value ( ) . display_sort_key ( ) ) ;
304+ self . metrics . sort_unstable_by_key ( |metric| {
305+ (
306+ metric. value ( ) . display_sort_key ( ) ,
307+ metric. value ( ) . name ( ) . to_owned ( ) ,
308+ )
309+ } ) ;
306310 self
307311 }
308312
@@ -665,7 +669,9 @@ mod tests {
665669 MetricBuilder :: new ( & metrics) . end_timestamp ( 0 ) ;
666670 MetricBuilder :: new ( & metrics) . start_timestamp ( 0 ) ;
667671 MetricBuilder :: new ( & metrics) . elapsed_compute ( 0 ) ;
672+ MetricBuilder :: new ( & metrics) . counter ( "the_second_counter" , 0 ) ;
668673 MetricBuilder :: new ( & metrics) . counter ( "the_counter" , 0 ) ;
674+ MetricBuilder :: new ( & metrics) . counter ( "the_third_counter" , 0 ) ;
669675 MetricBuilder :: new ( & metrics) . subset_time ( "the_time" , 0 ) ;
670676 MetricBuilder :: new ( & metrics) . output_rows ( 0 ) ;
671677 let metrics = metrics. clone_inner ( ) ;
@@ -675,9 +681,9 @@ mod tests {
675681 n. join ( ", " )
676682 }
677683
678- assert_eq ! ( "end_timestamp, start_timestamp, elapsed_compute, the_counter, the_time, output_rows" , metric_names( & metrics) ) ;
684+ assert_eq ! ( "end_timestamp, start_timestamp, elapsed_compute, the_second_counter, the_counter, the_third_counter , the_time, output_rows" , metric_names( & metrics) ) ;
679685
680686 let metrics = metrics. sorted_for_display ( ) ;
681- assert_eq ! ( "output_rows, elapsed_compute, the_counter, the_time, start_timestamp, end_timestamp" , metric_names( & metrics) ) ;
687+ assert_eq ! ( "output_rows, elapsed_compute, the_counter, the_second_counter, the_third_counter, the_time, start_timestamp, end_timestamp" , metric_names( & metrics) ) ;
682688 }
683689}
0 commit comments