Skip to content

Commit f988b23

Browse files
authored
ethdb, internal/ethapi: support exposing Pebble stats too, beside LevelDB (#28224)
ethdb, internal/ethapi: support exposing Pebble stats too, besinde LevelDB
1 parent b9450bf commit f988b23

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

ethdb/leveldb/leveldb.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package leveldb
2222

2323
import (
2424
"fmt"
25+
"strings"
2526
"sync"
2627
"time"
2728

@@ -245,6 +246,11 @@ func (db *Database) NewSnapshot() (ethdb.Snapshot, error) {
245246

246247
// Stat returns a particular internal stat of the database.
247248
func (db *Database) Stat(property string) (string, error) {
249+
if property == "" {
250+
property = "leveldb.stats"
251+
} else if !strings.HasPrefix(property, "leveldb.") {
252+
property = "leveldb." + property
253+
}
248254
return db.db.GetProperty(property)
249255
}
250256

ethdb/pebble/pebble.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,12 @@ func upperBound(prefix []byte) (limit []byte) {
379379
return limit
380380
}
381381

382-
// Stat returns a particular internal stat of the database.
382+
// Stat returns the internal metrics of Pebble in a text format. It's a developer
383+
// method to read everything there is to read independent of Pebble version.
384+
//
385+
// The property is unused in Pebble as there's only one thing to retrieve.
383386
func (d *Database) Stat(property string) (string, error) {
384-
return "", nil
387+
return d.db.Metrics().String(), nil
385388
}
386389

387390
// Compact flattens the underlying data store for the given key range. In essence,

internal/ethapi/api.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,11 +2191,6 @@ func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, err
21912191

21922192
// ChaindbProperty returns leveldb properties of the key-value database.
21932193
func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
2194-
if property == "" {
2195-
property = "leveldb.stats"
2196-
} else if !strings.HasPrefix(property, "leveldb.") {
2197-
property = "leveldb." + property
2198-
}
21992194
return api.b.ChainDb().Stat(property)
22002195
}
22012196

0 commit comments

Comments
 (0)