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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
package cache
import "github.com/prometheus/client_golang/prometheus"
var (
requestTotals = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_requests_total",
Help: "Total number of disk cache requests",
},
)
missTotals = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_miss_total",
Help: "Total number of disk cache misses",
},
)
bytesStoredtotals = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_bytes_stored_total",
Help: "Total number of disk cache bytes stored",
},
)
bytesFetchedtotals = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_bytes_fetched_total",
Help: "Total number of disk cache bytes fetched",
},
)
bytesLoserTotals = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_bytes_loser_total",
Help: "Total number of disk cache bytes from losing writes",
},
)
errTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gitaly_diskcache_errors_total",
Help: "Total number of errors encountered by disk cache",
},
[]string{"error"},
)
walkerCheckTotal = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_walker_check_total",
Help: "Total number of events during diskcache filesystem walks",
},
)
walkerRemovalTotal = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_walker_removal_total",
Help: "Total number of events during diskcache filesystem walks",
},
)
walkerErrorTotal = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "gitaly_diskcache_walker_error_total",
Help: "Total number of errors during diskcache filesystem walks",
},
)
)
func init() {
prometheus.MustRegister(requestTotals)
prometheus.MustRegister(missTotals)
prometheus.MustRegister(bytesStoredtotals)
prometheus.MustRegister(bytesFetchedtotals)
prometheus.MustRegister(bytesLoserTotals)
prometheus.MustRegister(errTotal)
prometheus.MustRegister(walkerCheckTotal)
prometheus.MustRegister(walkerRemovalTotal)
prometheus.MustRegister(walkerErrorTotal)
}
func countErr(err error) error {
switch err {
case ErrMissingLeaseFile:
errTotal.WithLabelValues("ErrMissingLeaseFile").Inc()
case ErrPendingExists:
errTotal.WithLabelValues("ErrPendingExists").Inc()
}
return err
}
var (
countRequest = func() { requestTotals.Inc() }
countMiss = func() { missTotals.Inc() }
countWriteBytes = func(n float64) { bytesStoredtotals.Add(n) }
countReadBytes = func(n float64) { bytesFetchedtotals.Add(n) }
countLoserBytes = func(n float64) { bytesLoserTotals.Add(n) }
countWalkRemoval = func() { walkerRemovalTotal.Inc() }
countWalkCheck = func() { walkerCheckTotal.Inc() }
countWalkError = func() { walkerErrorTotal.Inc() }
)
|