This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
sets.go
63 lines (56 loc) · 1.36 KB
/
sets.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
package main
import (
"strings"
as "github.com/aerospike/aerospike-client-go"
"github.com/prometheus/client_golang/prometheus"
)
var (
// SetMetrics lists the keys we report from aero's sets
// command.
// See `asinfo -l -v sets` for the full list.
SetMetrics = []metric{
gauge("memory_data_bytes", "memory data bytes"),
gauge("objects", "objects"),
gauge("truncate_lut", "The most covering truncate_lut for this set"),
counter("stop-writes-count", "stop writes count"),
}
)
type setCollector cmetrics
func newSetCollector() setCollector {
set := map[string]cmetric{}
for _, m := range SetMetrics {
set[m.aeroName] = cmetric{
typ: m.typ,
desc: prometheus.NewDesc(
promkey(systemSet, m.aeroName),
m.desc,
[]string{"namespace", "set"},
nil,
),
}
}
return set
}
func (setc setCollector) describe(ch chan<- *prometheus.Desc) {
for _, s := range setc {
ch <- s.desc
}
}
func (setc setCollector) collect(conn *as.Connection) ([]prometheus.Metric, error) {
var metrics []prometheus.Metric
info, err := as.RequestInfo(conn, "sets")
if err != nil {
return nil, err
}
for _, setInfo := range strings.Split(info["sets"], ";") {
if setInfo == "" {
continue
}
setStats := parseInfo(setInfo)
metrics = append(
metrics,
infoCollect(cmetrics(setc), setInfo, setStats["ns"], setStats["set"])...,
)
}
return metrics, nil
}