@@ -93,7 +93,8 @@ type Database struct {
93
93
commitWALRotation atomic.Int64
94
94
commitWait atomic.Int64
95
95
96
- levelsGauge []metrics.Gauge // Gauge for tracking the number of tables in levels
96
+ level0SublevelsGauge metrics.Gauge
97
+ levelsGauge []metrics.Gauge // Gauge for tracking the number of tables in levels
97
98
98
99
quitLock sync.RWMutex // Mutex protecting the quit channel and the closed flag
99
100
quitChan chan chan error // Quit channel to stop the metrics collection before closing the database
@@ -329,6 +330,8 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e
329
330
db .commitWALRotationMeter = metrics .GetOrRegisterMeter (namespace + "commit/duration/walrotation" , nil )
330
331
db .commitWaitMeter = metrics .GetOrRegisterMeter (namespace + "commit/duration/commitwait" , nil )
331
332
333
+ db .level0SublevelsGauge = metrics .GetOrRegisterGauge (namespace + "tables/level0/sublevels" , nil )
334
+
332
335
// Start up the metrics gathering and return
333
336
go db .meter (metricsGatheringInterval , namespace )
334
337
return db , nil
@@ -650,6 +653,9 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
650
653
d .compDebtGauge .Update (int64 (stats .Compact .EstimatedDebt ))
651
654
d .compInProgressGauge .Update (stats .Compact .NumInProgress )
652
655
656
+ if len (stats .Levels ) > 0 {
657
+ d .level0SublevelsGauge .Update (int64 (stats .Levels [0 ].Sublevels ))
658
+ }
653
659
for i , level := range stats .Levels {
654
660
// Append metrics for additional layers
655
661
if i >= len (d .levelsGauge ) {
0 commit comments