Skip to content

Commit

Permalink
feat: add wal write system call metrics observation
Browse files Browse the repository at this point in the history
Signed-off-by: Qiuyu Wu <[email protected]>
  • Loading branch information
Qiuyu Wu committed Mar 20, 2024
1 parent 3191002 commit 2f64140
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/storage/wal/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io"
"os"
"sync"
"time"

"go.etcd.io/etcd/pkg/v3/crc"
"go.etcd.io/etcd/pkg/v3/ioutil"
Expand Down Expand Up @@ -92,7 +93,9 @@ func (e *encoder) encode(rec *walpb.Record) error {
if padBytes != 0 {
data = append(data, make([]byte, padBytes)...)
}
start := time.Now()
n, err = e.bw.Write(data)
walWriteSec.Observe(time.Since(start).Seconds())
walWriteBytes.Add(float64(n))
return err
}
Expand Down
9 changes: 9 additions & 0 deletions server/storage/wal/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ var (
Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
})

walWriteSec = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "etcd",
Subsystem: "disk",
Name: "wal_write_duration_seconds",
Help: "The latency distributions of write called by WAL.",

Buckets: prometheus.ExponentialBuckets(0.001, 2, 14),
})

walWriteBytes = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "etcd",
Subsystem: "disk",
Expand Down

0 comments on commit 2f64140

Please sign in to comment.