Skip to content

Commit

Permalink
ethdb, internal/ethapi: support exposing Pebble stats too, beside Lev…
Browse files Browse the repository at this point in the history
…elDB (ethereum#28224)

ethdb, internal/ethapi: support exposing Pebble stats too, besinde LevelDB
  • Loading branch information
karalabe authored and tyler-smith committed Oct 16, 2023
1 parent 6378a99 commit bb668af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ethdb/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package leveldb

import (
"fmt"
"strings"
"sync"
"time"

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

// Stat returns a particular internal stat of the database.
func (db *Database) Stat(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return db.db.GetProperty(property)
}

Expand Down
7 changes: 5 additions & 2 deletions ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,12 @@ func upperBound(prefix []byte) (limit []byte) {
return limit
}

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

// Compact flattens the underlying data store for the given key range. In essence,
Expand Down
5 changes: 0 additions & 5 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2193,11 +2193,6 @@ func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, err

// ChaindbProperty returns leveldb properties of the key-value database.
func (api *DebugAPI) ChaindbProperty(property string) (string, error) {
if property == "" {
property = "leveldb.stats"
} else if !strings.HasPrefix(property, "leveldb.") {
property = "leveldb." + property
}
return api.b.ChainDb().Stat(property)
}

Expand Down

0 comments on commit bb668af

Please sign in to comment.