Skip to content

Commit

Permalink
mvcc: add "etcd_mvcc_range_total", "etcd_mvcc_txn_total"
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 8276226 commit 3f12ffb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mvcc/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import (

var (
rangeCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "etcd",
Subsystem: "mvcc",
Name: "range_total",
Help: "Total number of ranges seen by this member.",
})
rangeCounterDebug = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "etcd_debugging",
Subsystem: "mvcc",
Expand Down Expand Up @@ -62,6 +69,13 @@ var (
})

txnCounter = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "etcd",
Subsystem: "mvcc",
Name: "txn_total",
Help: "Total number of txns seen by this member.",
})
txnCounterDebug = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "etcd_debugging",
Subsystem: "mvcc",
Expand Down Expand Up @@ -254,11 +268,13 @@ var (

func init() {
prometheus.MustRegister(rangeCounter)
prometheus.MustRegister(rangeCounterDebug)
prometheus.MustRegister(putCounter)
prometheus.MustRegister(putCounterDebug)
prometheus.MustRegister(deleteCounter)
prometheus.MustRegister(deleteCounterDebug)
prometheus.MustRegister(txnCounter)
prometheus.MustRegister(txnCounterDebug)
prometheus.MustRegister(keysGauge)
prometheus.MustRegister(watchStreamGauge)
prometheus.MustRegister(watcherGauge)
Expand Down
6 changes: 5 additions & 1 deletion mvcc/metrics_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ func (tw *metricsTxnWrite) End() {
defer tw.TxnWrite.End()
if sum := tw.ranges + tw.puts + tw.deletes; sum > 1 {
txnCounter.Inc()
txnCounterDebug.Inc()
}
rangeCounter.Add(float64(tw.ranges))

ranges := float64(tw.ranges)
rangeCounter.Add(ranges)
rangeCounterDebug.Add(ranges)

puts := float64(tw.puts)
putCounter.Add(puts)
Expand Down

0 comments on commit 3f12ffb

Please sign in to comment.