-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
43 lines (38 loc) · 989 Bytes
/
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
package mutable
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type metrics struct {
CacheAccess *prometheus.CounterVec
CacheSize *prometheus.GaugeVec
}
func newMetrics(reg prometheus.Registerer) *metrics {
return &metrics{
CacheSize: promauto.With(reg).NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "squirreldb",
Subsystem: "mutable",
Name: "cache_size",
Help: "Number of entries stored in the cache",
},
[]string{"cache"},
),
CacheAccess: promauto.With(reg).NewCounterVec(
prometheus.CounterOpts{
Namespace: "squirreldb",
Subsystem: "mutable",
Name: "cache_access_total",
Help: "Total number of access to the cache",
},
[]string{"cache", "status"},
),
}
}
// metricStatus returns the cache status given whether the entry was found or not.
func metricStatus(found bool) string {
if found {
return "hit"
}
return "miss"
}