forked from hashicorp/raft-wal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetrics.go
79 lines (75 loc) · 2.99 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) HashiCorp, Inc
// SPDX-License-Identifier: MPL-2.0
package wal
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type Metrics struct {
BytesWritten prometheus.Counter
EntriesWritten prometheus.Counter
Appends prometheus.Counter
EntryBytesRead prometheus.Counter
EntriesRead prometheus.Counter
SegmentRotations prometheus.Counter
EntriesTruncated *prometheus.CounterVec
Truncations *prometheus.CounterVec
LastSegmentAgeSeconds prometheus.Gauge
}
func newWALMetrics(reg prometheus.Registerer) *Metrics {
return &Metrics{
BytesWritten: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "entry_bytes_written",
Help: "entry_bytes_written counts the bytes of log entry after encoding." +
" Actual bytes written to disk might be slightly higher as it" +
" includes headers and index entries.",
}),
EntriesWritten: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "entries_written",
Help: "entries_written counts the number of entries written.",
}),
Appends: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "appends",
Help: "appends counts the number of calls to StoreLog(s) i.e." +
" number of batches of entries appended.",
}),
EntryBytesRead: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "entry_bytes_read",
Help: "entry_bytes_read counts the bytes of log entry read from" +
" segments before decoding. actual bytes read from disk might be higher" +
" as it includes headers and index entries and possible secondary reads" +
" for large entries that don't fit in buffers.",
}),
EntriesRead: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "entries_read",
Help: "entries_read counts the number of calls to get_log.",
}),
SegmentRotations: promauto.With(reg).NewCounter(prometheus.CounterOpts{
Name: "segment_rotations",
Help: "segment_rotations counts how many times we move to a new segment file.",
}),
EntriesTruncated: promauto.With(reg).NewCounterVec(
prometheus.CounterOpts{
Name: "entries_truncated_total",
Help: "entries_truncated counts how many log entries have been truncated" +
" from the front or back.",
},
[]string{"type"},
),
Truncations: promauto.With(reg).NewCounterVec(
prometheus.CounterOpts{
Name: "truncations_total",
Help: "truncations is the number of truncate calls categorized by whether" +
" the call was successful or not.",
},
[]string{"type", "success"},
),
LastSegmentAgeSeconds: promauto.With(reg).NewGauge(prometheus.GaugeOpts{
Name: "last_segment_age_seconds",
Help: "last_segment_age_seconds is a gauge that is set each time we" +
" rotate a segment and describes the number of seconds between when" +
" that segment file was first created and when it was sealed. this" +
" gives a rough estimate how quickly writes are filling the disk.",
}),
}
}