From 563d9e3254fba8ec62da7fc67c411dff1bb5ed5b Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 11 Jun 2018 13:40:34 -0700 Subject: [PATCH] backend: more metrics for bboltdb transcation --- mvcc/backend/batch_tx.go | 3 +++ mvcc/backend/metrics.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/mvcc/backend/batch_tx.go b/mvcc/backend/batch_tx.go index dad95b045a35..3a2a0ed7ae42 100644 --- a/mvcc/backend/batch_tx.go +++ b/mvcc/backend/batch_tx.go @@ -220,6 +220,9 @@ func (t *batchTx) commit(stop bool) { err := t.tx.Commit() // gofail: var afterCommit struct{} + rebalanceSec.Observe(t.tx.Stats().RebalanceTime.Seconds()) + spillSec.Observe(t.tx.Stats().SpillTime.Seconds()) + writeSec.Observe(t.tx.Stats().WriteTime.Seconds()) commitSec.Observe(time.Since(start).Seconds()) atomic.AddInt64(&t.backend.commits, 1) diff --git a/mvcc/backend/metrics.go b/mvcc/backend/metrics.go index dda36a57a381..c25042d6d5ef 100644 --- a/mvcc/backend/metrics.go +++ b/mvcc/backend/metrics.go @@ -28,6 +28,39 @@ var ( Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), }) + rebalanceSec = prometheus.NewHistogram(prometheus.HistogramOpts{ + Namespace: "etcd_debugging", + Subsystem: "disk", + Name: "backend_rebalance_duration_seconds", + Help: "The latency distributions of commit.rebalance called by bboltdb backend.", + + // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2 + // highest bucket start of 0.001 sec * 2^13 == 8.192 sec + Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), + }) + + spillSec = prometheus.NewHistogram(prometheus.HistogramOpts{ + Namespace: "etcd_debugging", + Subsystem: "disk", + Name: "backend_commit_duration_seconds", + Help: "The latency distributions of commit.spill called by bboltdb backend.", + + // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2 + // highest bucket start of 0.001 sec * 2^13 == 8.192 sec + Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), + }) + + writeSec = prometheus.NewHistogram(prometheus.HistogramOpts{ + Namespace: "etcd_debugging", + Subsystem: "disk", + Name: "backend_commit_duration_seconds", + Help: "The latency distributions of commit.write called by bboltdb backend.", + + // lowest bucket start of upper bound 0.001 sec (1 ms) with factor 2 + // highest bucket start of 0.001 sec * 2^13 == 8.192 sec + Buckets: prometheus.ExponentialBuckets(0.001, 2, 14), + }) + defragSec = prometheus.NewHistogram(prometheus.HistogramOpts{ Namespace: "etcd", Subsystem: "disk",