Skip to content

Commit

Permalink
Merge pull request #355 from OffchainLabs/pebble-sublevels-metric
Browse files Browse the repository at this point in the history
add pebble l0 sublevels metric
  • Loading branch information
joshuacolvin0 authored Nov 6, 2024
2 parents cccbae5 + f97145e commit 2ab7e39
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 @@ -93,7 +93,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 @@ -329,6 +330,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 @@ -650,6 +653,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 2ab7e39

Please sign in to comment.