forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 5
/
metrics.go
72 lines (67 loc) · 1.87 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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package resource
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/MetalBlockchain/metalgo/utils/wrappers"
)
type metrics struct {
numCPUCycles *prometheus.GaugeVec
numDiskReads *prometheus.GaugeVec
numDiskReadBytes *prometheus.GaugeVec
numDiskWrites *prometheus.GaugeVec
numDiskWritesBytes *prometheus.GaugeVec
}
func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, error) {
m := &metrics{
numCPUCycles: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "num_cpu_cycles",
Help: "Total number of CPU cycles",
},
[]string{"processID"},
),
numDiskReads: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "num_disk_reads",
Help: "Total number of disk reads",
},
[]string{"processID"},
),
numDiskReadBytes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "num_disk_read_bytes",
Help: "Total number of disk read bytes",
},
[]string{"processID"},
),
numDiskWrites: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "num_disk_writes",
Help: "Total number of disk writes",
},
[]string{"processID"},
),
numDiskWritesBytes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Name: "num_disk_write_bytes",
Help: "Total number of disk write bytes",
},
[]string{"processID"},
),
}
errs := wrappers.Errs{}
errs.Add(
registerer.Register(m.numCPUCycles),
registerer.Register(m.numDiskReads),
registerer.Register(m.numDiskReadBytes),
registerer.Register(m.numDiskWrites),
registerer.Register(m.numDiskWritesBytes),
)
return m, errs.Err
}