diff --git a/mvcc/metrics.go b/mvcc/metrics.go index a65fe59b9..895522817 100644 --- a/mvcc/metrics.go +++ b/mvcc/metrics.go @@ -131,7 +131,7 @@ var ( Buckets: prometheus.ExponentialBuckets(100, 2, 14), }) - dbTotalSize = prometheus.NewGaugeFunc(prometheus.GaugeOpts{ + dbTotalSizeDebugging = prometheus.NewGaugeFunc(prometheus.GaugeOpts{ Namespace: "etcd_debugging", Subsystem: "mvcc", Name: "db_total_size_in_bytes", @@ -143,9 +143,21 @@ var ( return reportDbTotalSizeInBytes() }, ) + dbTotalSize = prometheus.NewGaugeFunc(prometheus.GaugeOpts{ + Namespace: "etcd", + Subsystem: "mvcc", + Name: "db_total_size_in_bytes", + Help: "Total size of the underlying database in bytes.", + }, + func() float64 { + reportDbTotalSizeInBytesMu.RLock() + defer reportDbTotalSizeInBytesMu.RUnlock() + return reportDbTotalSizeInBytes() + }, + ) // overridden by mvcc initialization reportDbTotalSizeInBytesMu sync.RWMutex - reportDbTotalSizeInBytes func() float64 = func() float64 { return 0 } + reportDbTotalSizeInBytes = func() float64 { return 0 } ) func init() { @@ -162,6 +174,7 @@ func init() { prometheus.MustRegister(indexCompactionPauseDurations) prometheus.MustRegister(dbCompactionPauseDurations) prometheus.MustRegister(dbCompactionTotalDurations) + prometheus.MustRegister(dbTotalSizeDebugging) prometheus.MustRegister(dbTotalSize) }