From 3e228d629e9283f3b46aebe9ddd787acd8eaecea Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 4 Sep 2024 17:26:17 +0200 Subject: [PATCH] add pebble l0 sublevels metric --- ethdb/pebble/pebble.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ethdb/pebble/pebble.go b/ethdb/pebble/pebble.go index ab6bb1d72d..5f87c26de3 100644 --- a/ethdb/pebble/pebble.go +++ b/ethdb/pebble/pebble.go @@ -89,7 +89,8 @@ type Database struct { commitWALRotation atomic.Int64 commitWait atomic.Int64 - levelsGauge []metrics.Gauge // Gauge for tracking the number of tables in levels + level0SublevelsGauge metrics.Gauge + levelsGauge []metrics.Gauge // Gauge for tracking the number of tables in levels quitLock sync.RWMutex // Mutex protecting the quit channel and the closed flag quitChan chan chan error // Quit channel to stop the metrics collection before closing the database @@ -320,6 +321,8 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e db.commitWALRotationMeter = metrics.GetOrRegisterMeter(namespace+"commit/duration/walrotation", nil) db.commitWaitMeter = metrics.GetOrRegisterMeter(namespace+"commit/duration/commitwait", nil) + db.level0SublevelsGauge = metrics.GetOrRegisterGauge(namespace+"tables/level0/sublevels", nil) + // Start up the metrics gathering and return go db.meter(metricsGatheringInterval, namespace) return db, nil @@ -632,6 +635,9 @@ func (d *Database) meter(refresh time.Duration, namespace string) { d.compDebtGauge.Update(int64(stats.Compact.EstimatedDebt)) d.compInProgressGauge.Update(stats.Compact.NumInProgress) + if len(stats.Levels) > 0 { + d.level0SublevelsGauge.Update(int64(stats.Levels[0].Sublevels)) + } for i, level := range stats.Levels { // Append metrics for additional layers if i >= len(d.levelsGauge) {