@@ -105,49 +105,7 @@ impl SummaryView {
105105 ) ) )
106106 . child ( views:: DummyView . fixed_width ( 1 ) )
107107 . child ( views:: TextView :: new ( "" ) . with_name ( "queries" ) )
108- . child ( views:: DummyView . fixed_width ( 1 ) )
109- . child ( views:: TextView :: new ( StyledString :: styled (
110- "Merges:" ,
111- BaseColor :: Cyan . dark ( ) ,
112- ) ) )
113- . child ( views:: DummyView . fixed_width ( 1 ) )
114- . child ( views:: TextView :: new ( "" ) . with_name ( "merges" ) )
115- . child ( views:: DummyView . fixed_width ( 1 ) )
116- . child ( views:: TextView :: new ( StyledString :: styled (
117- "Mutations:" ,
118- BaseColor :: Cyan . dark ( ) ,
119- ) ) )
120- . child ( views:: DummyView . fixed_width ( 1 ) )
121- . child ( views:: TextView :: new ( "" ) . with_name ( "mutations" ) )
122- . child ( views:: DummyView . fixed_width ( 1 ) )
123- . child ( views:: TextView :: new ( StyledString :: styled (
124- "Fetches:" ,
125- BaseColor :: Cyan . dark ( ) ,
126- ) ) )
127- . child ( views:: DummyView . fixed_width ( 1 ) )
128- . child ( views:: TextView :: new ( "" ) . with_name ( "fetches" ) )
129- . child ( views:: DummyView . fixed_width ( 1 ) )
130- . child ( views:: TextView :: new ( StyledString :: styled (
131- "RepQueue:" ,
132- BaseColor :: Cyan . dark ( ) ,
133- ) ) )
134- . child ( views:: DummyView . fixed_width ( 1 ) )
135- . child ( views:: TextView :: new ( "" ) . with_name ( "replication_queue" ) )
136- . child ( views:: DummyView . fixed_width ( 1 ) )
137- . child ( views:: TextView :: new ( StyledString :: styled (
138- "Buffers:" ,
139- BaseColor :: Cyan . dark ( ) ,
140- ) ) )
141- . child ( views:: DummyView . fixed_width ( 1 ) )
142- . child ( views:: TextView :: new ( "" ) . with_name ( "storage_buffer_bytes" ) )
143- . child ( views:: DummyView . fixed_width ( 1 ) )
144- . child ( views:: TextView :: new ( StyledString :: styled (
145- "DistInserts:" ,
146- BaseColor :: Cyan . dark ( ) ,
147- ) ) )
148- . child ( views:: DummyView . fixed_width ( 1 ) )
149- . child ( views:: TextView :: new ( "" ) . with_name ( "storage_distributed_insert_files" ) )
150- . child ( views:: DummyView . fixed_width ( 1 ) ) ,
108+ . child ( views:: TextView :: new ( "" ) . with_name ( "optional_metrics" ) ) ,
151109 )
152110 . child (
153111 views:: LinearLayout :: horizontal ( )
@@ -465,71 +423,86 @@ impl SummaryView {
465423
466424 {
467425 self . sparklines . merges . push ( summary. merges as f64 ) ;
468- let mut content = StyledString :: plain ( "" ) ;
469- content. append_styled (
470- summary. merges . to_string ( ) ,
471- get_color_for_ratio ( summary. merges , summary. servers * 20 ) ,
472- ) ;
473- let spark = self . sparklines . merges . render ( SPARKLINE_WIDTH ) ;
474- if !spark. is_empty ( ) {
475- content. append_plain ( " " ) ;
476- content. append_styled ( spark, BaseColor :: White . dark ( ) ) ;
426+
427+ let mut opt = StyledString :: new ( ) ;
428+ let mut add_opt = |label : & str , content : StyledString | {
429+ if !opt. is_empty ( ) {
430+ opt. append_plain ( " " ) ;
431+ }
432+ opt. append_styled ( label, BaseColor :: Cyan . dark ( ) ) ;
433+ opt. append_plain ( " " ) ;
434+ opt. append ( content) ;
435+ } ;
436+
437+ if summary. merges > 0 {
438+ let mut c = StyledString :: new ( ) ;
439+ c. append_styled (
440+ summary. merges . to_string ( ) ,
441+ get_color_for_ratio ( summary. merges , summary. servers * 20 ) ,
442+ ) ;
443+ let spark = self . sparklines . merges . render ( SPARKLINE_WIDTH ) ;
444+ if !spark. is_empty ( ) {
445+ c. append_plain ( " " ) ;
446+ c. append_styled ( spark, BaseColor :: White . dark ( ) ) ;
447+ }
448+ add_opt ( "Merges:" , c) ;
477449 }
478- self . set_view_content ( "merges" , content) ;
479- }
480450
481- {
482- let mut content = StyledString :: plain ( "" ) ;
483- content . append_styled (
484- summary. mutations . to_string ( ) ,
485- get_color_for_ratio ( summary. mutations , summary. servers * 8 ) ,
486- ) ;
487- self . set_view_content ( "mutations ", content ) ;
488- }
451+ if summary . mutations > 0 {
452+ let mut c = StyledString :: new ( ) ;
453+ c . append_styled (
454+ summary. mutations . to_string ( ) ,
455+ get_color_for_ratio ( summary. mutations , summary. servers * 8 ) ,
456+ ) ;
457+ add_opt ( "Mutations: ", c ) ;
458+ }
489459
490- {
491- let mut content = StyledString :: plain ( "" ) ;
492- content. append_styled (
493- summary. replication_queue . to_string ( ) ,
494- get_color_for_ratio ( summary. replication_queue , summary. servers * 20 ) ,
495- ) ;
496- content. append ( " (" ) ;
497- content. append_styled (
498- summary. replication_queue_tries . to_string ( ) ,
499- get_color_for_ratio (
500- summary. replication_queue_tries ,
501- summary. replication_queue * 2 ,
502- ) ,
503- ) ;
504- content. append ( ")" ) ;
505- self . set_view_content ( "replication_queue" , content) ;
506- }
460+ if summary. fetches > 0 {
461+ let mut c = StyledString :: new ( ) ;
462+ c. append_styled (
463+ summary. fetches . to_string ( ) ,
464+ get_color_for_ratio ( summary. fetches , summary. servers * 20 ) ,
465+ ) ;
466+ add_opt ( "Fetches:" , c) ;
467+ }
507468
508- {
509- let mut content = StyledString :: plain ( "" ) ;
510- content. append_styled (
511- summary. fetches . to_string ( ) ,
512- get_color_for_ratio ( summary. fetches , summary. servers * 20 ) ,
513- ) ;
514- self . set_view_content ( "fetches" , content) ;
515- }
469+ if summary. replication_queue > 0 {
470+ let mut c = StyledString :: new ( ) ;
471+ c. append_styled (
472+ summary. replication_queue . to_string ( ) ,
473+ get_color_for_ratio ( summary. replication_queue , summary. servers * 20 ) ,
474+ ) ;
475+ c. append ( " (" ) ;
476+ c. append_styled (
477+ summary. replication_queue_tries . to_string ( ) ,
478+ get_color_for_ratio (
479+ summary. replication_queue_tries ,
480+ summary. replication_queue * 2 ,
481+ ) ,
482+ ) ;
483+ c. append ( ")" ) ;
484+ add_opt ( "RepQueue:" , c) ;
485+ }
516486
517- {
518- let mut content = StyledString :: plain ( "" ) ;
519- content . append_styled (
520- fmt_ref. format ( summary. storages . buffer_bytes as i64 ) ,
521- get_color_for_ratio ( summary. storages . buffer_bytes , summary. memory . os_total ) ,
522- ) ;
523- self . set_view_content ( "storage_buffer_bytes ", content ) ;
524- }
487+ if summary . storages . buffer_bytes > 0 {
488+ let mut c = StyledString :: new ( ) ;
489+ c . append_styled (
490+ fmt_ref. format ( summary. storages . buffer_bytes as i64 ) ,
491+ get_color_for_ratio ( summary. storages . buffer_bytes , summary. memory . os_total ) ,
492+ ) ;
493+ add_opt ( "Buffers: ", c ) ;
494+ }
525495
526- {
527- let mut content = StyledString :: plain ( "" ) ;
528- content. append_styled (
529- summary. storages . distributed_insert_files . to_string ( ) ,
530- get_color_for_ratio ( summary. storages . distributed_insert_files , 10000 ) ,
531- ) ;
532- self . set_view_content ( "storage_distributed_insert_files" , content) ;
496+ if summary. storages . distributed_insert_files > 0 {
497+ let mut c = StyledString :: new ( ) ;
498+ c. append_styled (
499+ summary. storages . distributed_insert_files . to_string ( ) ,
500+ get_color_for_ratio ( summary. storages . distributed_insert_files , 10000 ) ,
501+ ) ;
502+ add_opt ( "DistInserts:" , c) ;
503+ }
504+
505+ self . set_view_content ( "optional_metrics" , opt) ;
533506 }
534507
535508 self . prev_summary = Some ( summary) ;
0 commit comments