ethdb, internal/ethapi: support exposing Pebble stats too, beside LevelDB (#28224)

ethdb, internal/ethapi: support exposing Pebble stats too, besinde LevelDB
This commit is contained in:
Péter Szilágyi 2023-09-28 22:27:21 +03:00 committed by GitHub
parent b9450bfcca
commit f988b2332e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

@ -22,6 +22,7 @@ package leveldb
import ( import (
"fmt" "fmt"
"strings"
"sync" "sync"
"time" "time"
@ -245,6 +246,11 @@ func (db *Database) NewSnapshot() (ethdb.Snapshot, error) {
// Stat returns a particular internal stat of the database. // Stat returns a particular internal stat of the database.
func (db *Database) Stat(property string) (string, error) { 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) return db.db.GetProperty(property)
} }

@ -379,9 +379,12 @@ func upperBound(prefix []byte) (limit []byte) {
return limit 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) { 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, // Compact flattens the underlying data store for the given key range. In essence,

@ -2191,11 +2191,6 @@ func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, err
// ChaindbProperty returns leveldb properties of the key-value database. // ChaindbProperty returns leveldb properties of the key-value database.
func (api *DebugAPI) ChaindbProperty(property string) (string, error) { 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) return api.b.ChainDb().Stat(property)
} }