@@ -14,6 +14,8 @@ use crate::util::{bincode, spawn_thread, Bytes};
1414
1515static DB_VERSION : u32 = 3 ;
1616
17+ const ROCKSDB_NUM_LEVELS : u32 = 7 ;
18+
1719#[ derive( Debug , Eq , PartialEq ) ]
1820pub struct DBRow {
1921 pub key : Vec < u8 > ,
@@ -389,7 +391,9 @@ impl DB {
389391
390392 pub fn start_stats_exporter ( & self , db_metrics : Arc < RocksDbMetrics > , db_name : & str ) {
391393 let db_arc = Arc :: clone ( & self . db ) ;
394+ let db_arc2 = Arc :: clone ( & self . db ) ;
392395 let label = db_name. to_string ( ) ;
396+ let label2 = label. clone ( ) ;
393397
394398 let update_gauge = move |gauge : & GaugeVec , property : & str | {
395399 if let Ok ( Some ( value) ) = db_arc. property_value ( property) {
@@ -433,6 +437,15 @@ impl DB {
433437 update_gauge ( & db_metrics. block_cache_capacity , "rocksdb.block-cache-capacity" ) ;
434438 update_gauge ( & db_metrics. block_cache_usage , "rocksdb.block-cache-usage" ) ;
435439 update_gauge ( & db_metrics. block_cache_pinned_usage , "rocksdb.block-cache-pinned-usage" ) ;
440+ for level in 0 ..ROCKSDB_NUM_LEVELS {
441+ let prop = format ! ( "rocksdb.num-files-at-level{}" , level) ;
442+ if let Ok ( Some ( value) ) = db_arc2. property_value ( & prop) {
443+ if let Ok ( v) = value. parse :: < f64 > ( ) {
444+ let level_str = level. to_string ( ) ;
445+ db_metrics. num_files_at_level . with_label_values ( & [ & label2, & level_str] ) . set ( v) ;
446+ }
447+ }
448+ }
436449 thread:: sleep ( Duration :: from_secs ( 5 ) ) ;
437450 } ) ;
438451 }
0 commit comments