Browse Source

wal: use Histogram for syncDuration

Xiang Li 10 years ago
parent
commit
1c7f52d931
3 changed files with 9 additions and 8 deletions
  1. 5 5
      Documentation/metrics.md
  2. 3 2
      wal/metrics.go
  3. 1 1
      wal/wal.go

+ 5 - 5
Documentation/metrics.md

@@ -32,12 +32,12 @@ Failed proposals (`proposal_failed_total`) are normally related to two issues: t
 
 ### wal
 
-| Name                               | Description                                      | Type    |
-|------------------------------------|--------------------------------------------------|---------|
-| fsync_durations_microseconds       | The latency distributions of fsync called by wal | Summary |
-| last_index_saved                   | The index of the last entry saved by wal         | Gauge   |
+| Name                               | Description                                      | Type      |
+|------------------------------------|--------------------------------------------------|-----------|
+| fsync_durations_seconds            | The latency distributions of fsync called by wal | Histogram |
+| last_index_saved                   | The index of the last entry saved by wal         | Gauge     |
 
-Abnormally high fsync duration (`fsync_durations_microseconds`) indicates disk issues and might cause the cluster to be unstable.
+Abnormally high fsync duration (`fsync_durations_seconds`) indicates disk issues and might cause the cluster to be unstable.
 
 
 ### http requests

+ 3 - 2
wal/metrics.go

@@ -17,11 +17,12 @@ package wal
 import "github.com/coreos/etcd/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
 
 var (
-	syncDurations = prometheus.NewSummary(prometheus.SummaryOpts{
+	syncDurations = prometheus.NewHistogram(prometheus.HistogramOpts{
 		Namespace: "etcd",
 		Subsystem: "wal",
-		Name:      "fsync_durations_microseconds",
+		Name:      "fsync_durations_seconds",
 		Help:      "The latency distributions of fsync called by wal.",
+		Buckets:   prometheus.ExponentialBuckets(0.001, 2, 14),
 	})
 	lastIndexSaved = prometheus.NewGauge(prometheus.GaugeOpts{
 		Namespace: "etcd",

+ 1 - 1
wal/wal.go

@@ -403,7 +403,7 @@ func (w *WAL) sync() error {
 	}
 	start := time.Now()
 	err := w.f.Sync()
-	syncDurations.Observe(float64(time.Since(start).Nanoseconds() / int64(time.Microsecond)))
+	syncDurations.Observe(float64(time.Since(start)) / float64(time.Second))
 	return err
 }