mvcc: server db size with "etcd_debugging" namespace for backward compatibility

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-06-07 10:22:51 -07:00
parent 21130d5fb6
commit f2db05a869
2 changed files with 21 additions and 0 deletions

View File

@ -323,6 +323,9 @@ func (s *store) restore() error {
reportDbTotalSizeInBytesMu.Lock()
reportDbTotalSizeInBytes = func() float64 { return float64(b.Size()) }
reportDbTotalSizeInBytesMu.Unlock()
reportDbTotalSizeInBytesDebuggingMu.Lock()
reportDbTotalSizeInBytesDebugging = func() float64 { return float64(b.Size()) }
reportDbTotalSizeInBytesDebuggingMu.Unlock()
reportDbTotalSizeInUseInBytesMu.Lock()
reportDbTotalSizeInUseInBytes = func() float64 { return float64(b.SizeInUse()) }
reportDbTotalSizeInUseInBytesMu.Unlock()

View File

@ -161,6 +161,23 @@ var (
reportDbTotalSizeInBytesMu sync.RWMutex
reportDbTotalSizeInBytes = func() float64 { return 0 }
// TODO: remove this in v3.5
dbTotalSizeDebugging = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: "etcd_debugging",
Subsystem: "mvcc",
Name: "db_total_size_in_bytes",
Help: "Total size of the underlying database physically allocated in bytes.",
},
func() float64 {
reportDbTotalSizeInBytesDebuggingMu.RLock()
defer reportDbTotalSizeInBytesDebuggingMu.RUnlock()
return reportDbTotalSizeInBytesDebugging()
},
)
// overridden by mvcc initialization
reportDbTotalSizeInBytesDebuggingMu sync.RWMutex
reportDbTotalSizeInBytesDebugging = func() float64 { return 0 }
dbTotalSizeInUse = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "mvcc",
@ -218,6 +235,7 @@ func init() {
prometheus.MustRegister(dbCompactionTotalMs)
prometheus.MustRegister(dbCompactionKeysCounter)
prometheus.MustRegister(dbTotalSize)
prometheus.MustRegister(dbTotalSizeDebugging)
prometheus.MustRegister(dbTotalSizeInUse)
prometheus.MustRegister(hashSec)
prometheus.MustRegister(hashRevSec)