Skip to content

Commit

Permalink
add pebble l0 sublevels metric
Browse files Browse the repository at this point in the history
  • Loading branch information
magicxyyz committed Sep 4, 2024
1 parent fb79423 commit 3e228d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3e228d6

Please sign in to comment.