-
Notifications
You must be signed in to change notification settings - Fork 672
/
metrics.go
66 lines (61 loc) · 1.61 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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package resource
import (
"errors"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
numCPUCycles *prometheus.GaugeVec
numDiskReads *prometheus.GaugeVec
numDiskReadBytes *prometheus.GaugeVec
numDiskWrites *prometheus.GaugeVec
numDiskWritesBytes *prometheus.GaugeVec
}
func newMetrics(registerer prometheus.Registerer) (*metrics, error) {
m := &metrics{
numCPUCycles: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "num_cpu_cycles",
Help: "Total number of CPU cycles",
},
[]string{"processID"},
),
numDiskReads: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "num_disk_reads",
Help: "Total number of disk reads",
},
[]string{"processID"},
),
numDiskReadBytes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "num_disk_read_bytes",
Help: "Total number of disk read bytes",
},
[]string{"processID"},
),
numDiskWrites: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "num_disk_writes",
Help: "Total number of disk writes",
},
[]string{"processID"},
),
numDiskWritesBytes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "num_disk_write_bytes",
Help: "Total number of disk write bytes",
},
[]string{"processID"},
),
}
err := errors.Join(
registerer.Register(m.numCPUCycles),
registerer.Register(m.numDiskReads),
registerer.Register(m.numDiskReadBytes),
registerer.Register(m.numDiskWrites),
registerer.Register(m.numDiskWritesBytes),
)
return m, err
}