Browse Source

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

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee 7 years ago
parent
commit
f2db05a869
2 changed files with 21 additions and 0 deletions
  1. 3 0
      mvcc/kvstore.go
  2. 18 0
      mvcc/metrics.go

+ 3 - 0
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()

+ 18 - 0
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)