From f2db05a86901daac2a1a057ff465618b0d0a402e Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Thu, 7 Jun 2018 10:22:51 -0700 Subject: [PATCH] mvcc: server db size with "etcd_debugging" namespace for backward compatibility Signed-off-by: Gyuho Lee --- mvcc/kvstore.go | 3 +++ mvcc/metrics.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/mvcc/kvstore.go b/mvcc/kvstore.go index a445f6a4a..9c7f5c3ad 100644 --- a/mvcc/kvstore.go +++ b/mvcc/kvstore.go @@ -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() diff --git a/mvcc/metrics.go b/mvcc/metrics.go index c7ea0ce4c..9163cc7c6 100644 --- a/mvcc/metrics.go +++ b/mvcc/metrics.go @@ -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)