Skip to content

Commit

Permalink
mvcc: clean up metrics names, add missing register calls
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Aug 1, 2019
1 parent 6804bd8 commit 8276226
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions mvcc/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,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()
reportDbTotalSizeInBytesDebugMu.Lock()
reportDbTotalSizeInBytesDebug = func() float64 { return float64(b.Size()) }
reportDbTotalSizeInBytesDebugMu.Unlock()
reportDbTotalSizeInUseInBytesMu.Lock()
reportDbTotalSizeInUseInBytes = func() float64 { return float64(b.SizeInUse()) }
reportDbTotalSizeInUseInBytesMu.Unlock()
Expand Down
18 changes: 9 additions & 9 deletions mvcc/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (
Name: "put_total",
Help: "Total number of puts seen by this member.",
})

// TODO: remove in 3.5 release
putCounterDebug = prometheus.NewCounter(
prometheus.CounterOpts{
Expand All @@ -53,7 +52,6 @@ var (
Name: "delete_total",
Help: "Total number of deletes seen by this member.",
})

// TODO: remove in 3.5 release
deleteCounterDebug = prometheus.NewCounter(
prometheus.CounterOpts{
Expand Down Expand Up @@ -180,21 +178,21 @@ var (
reportDbTotalSizeInBytes = func() float64 { return 0 }

// TODO: remove this in v3.5
dbTotalSizeDebugging = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
dbTotalSizeDebug = 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()
reportDbTotalSizeInBytesDebugMu.RLock()
defer reportDbTotalSizeInBytesDebugMu.RUnlock()
return reportDbTotalSizeInBytesDebug()
},
)
// overridden by mvcc initialization
reportDbTotalSizeInBytesDebuggingMu sync.RWMutex
reportDbTotalSizeInBytesDebugging = func() float64 { return 0 }
reportDbTotalSizeInBytesDebugMu sync.RWMutex
reportDbTotalSizeInBytesDebug = func() float64 { return 0 }

dbTotalSizeInUse = prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: "etcd",
Expand Down Expand Up @@ -257,7 +255,9 @@ var (
func init() {
prometheus.MustRegister(rangeCounter)
prometheus.MustRegister(putCounter)
prometheus.MustRegister(putCounterDebug)
prometheus.MustRegister(deleteCounter)
prometheus.MustRegister(deleteCounterDebug)
prometheus.MustRegister(txnCounter)
prometheus.MustRegister(keysGauge)
prometheus.MustRegister(watchStreamGauge)
Expand All @@ -270,7 +270,7 @@ func init() {
prometheus.MustRegister(dbCompactionTotalMs)
prometheus.MustRegister(dbCompactionKeysCounter)
prometheus.MustRegister(dbTotalSize)
prometheus.MustRegister(dbTotalSizeDebugging)
prometheus.MustRegister(dbTotalSizeDebug)
prometheus.MustRegister(dbTotalSizeInUse)
prometheus.MustRegister(dbOpenReadTxN)
prometheus.MustRegister(hashSec)
Expand Down
14 changes: 8 additions & 6 deletions mvcc/metrics_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ func (tw *metricsTxnWrite) End() {
txnCounter.Inc()
}
rangeCounter.Add(float64(tw.ranges))
putCounter.Add(float64(tw.puts))
// TODO: remove in 3.5 release
putCounterDebug.Add(float64(tw.puts))
deleteCounter.Add(float64(tw.deletes))
// TODO: remove in 3.5 release
deleteCounterDebug.Add(float64(tw.deletes))

puts := float64(tw.puts)
putCounter.Add(puts)
putCounterDebug.Add(puts)

deletes := float64(tw.deletes)
deleteCounter.Add(deletes)
deleteCounterDebug.Add(deletes)
}

0 comments on commit 8276226

Please sign in to comment.