From 2f1730fcae42236d986cd1c5b26ad62480c04849 Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 11 Jun 2018 13:40:34 -0700 Subject: [PATCH 1/2] backend: more metrics for bboltdb transcation --- mvcc/backend/batch_tx.go | 3 +++ mvcc/backend/metrics.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/mvcc/backend/batch_tx.go b/mvcc/backend/batch_tx.go index dad95b045a3..3a2a0ed7ae4 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 dda36a57a38..d9641af7ae2 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_commit_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_spill_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_write_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", @@ -54,6 +87,9 @@ var ( func init() { prometheus.MustRegister(commitSec) + prometheus.MustRegister(rebalanceSec) + prometheus.MustRegister(spillSec) + prometheus.MustRegister(writeSec) prometheus.MustRegister(defragSec) prometheus.MustRegister(snapshotTransferSec) } From 63c482e430cd6757e921b161e449e64f5a53a64a Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 11 Jun 2018 13:40:34 -0700 Subject: [PATCH 2/2] CHANGELOG: highlight new backend metrics --- CHANGELOG-3.4.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG-3.4.md b/CHANGELOG-3.4.md index c2cd6a17f1e..8adcece5d12 100644 --- a/CHANGELOG-3.4.md +++ b/CHANGELOG-3.4.md @@ -147,6 +147,9 @@ See [code changes](https://github.com/coreos/etcd/compare/v3.3.0...v3.4.0) and [ - Add [`etcd_mvcc_hash_rev_duration_seconds`](https://github.com/coreos/etcd/pull/9761) Prometheus metric. - Rename [`etcd_debugging_mvcc_db_total_size_in_bytes` to `etcd_mvcc_db_total_size_in_bytes`](https://github.com/coreos/etcd/pull/9819). - Add [`etcd_mvcc_db_total_size_in_use_in_bytes`](https://github.com/coreos/etcd/pull/9256) Prometheus metric (renamed from [`etcd_debugging_mvcc_db_total_size_in_use_in_bytes`](https://github.com/coreos/etcd/pull/9819)). +- Add [`etcd_debugging_disk_backend_commit_rebalance_duration_seconds`](https://github.com/coreos/etcd/pull/9834) Prometheus metric. +- Add [`etcd_debugging_disk_backend_commit_spill_duration_seconds`](https://github.com/coreos/etcd/pull/9834) Prometheus metric. +- Add [`etcd_debugging_disk_backend_commit_write_duration_seconds`](https://github.com/coreos/etcd/pull/9834) Prometheus metric. - Add [`etcd_debugging_lease_granted_total`](https://github.com/coreos/etcd/pull/9778) Prometheus metric. - Add [`etcd_debugging_lease_revoked_total`](https://github.com/coreos/etcd/pull/9778) Prometheus metric. - Add [`etcd_debugging_lease_renewed_total`](https://github.com/coreos/etcd/pull/9778) Prometheus metric.