forked from ianlancetaylor/cgosymbolizer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcgomemprof_metrics.go
More file actions
112 lines (97 loc) · 2.77 KB
/
Copy pathcgomemprof_metrics.go
File metadata and controls
112 lines (97 loc) · 2.77 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//go:build with_jemalloc && linux
// +build with_jemalloc,linux
package cgosymbolizer
import (
"log"
"github.com/prometheus/client_golang/prometheus"
)
// RegisterJemallocStatsMetrics registers the jemalloc metrics with the given namespace, subsystem, and constLabels.
func RegisterJemallocStatsMetrics(namespace string, r prometheus.Registerer) {
if !IsJemallocStatsEnabled() {
log.Println("jemalloc stats is not enabled, skipping metric registration")
return
}
log.Println("register jemalloc stats metrics")
subsystem := "jemalloc"
for _, c := range []prometheus.Collector{
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "allocated",
}, func() float64 {
return float64(GetAllocatedMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "active",
}, func() float64 {
return float64(GetActiveMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "metadata",
}, func() float64 {
return float64(GetMetadataMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "metadata_thp",
}, func() float64 {
return float64(GetMetadataThpMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "resident",
}, func() float64 {
return float64(GetResidentMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "mapped",
}, func() float64 {
return float64(GetMappedMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "retained",
}, func() float64 {
return float64(GetRetainedMemory())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "zero_reallocs",
}, func() float64 {
return float64(GetZeroReallocs())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "background_thread_num_threads",
}, func() float64 {
return float64(GetBackgroundThreadNumThreads())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "background_thread_num_runs",
}, func() float64 {
return float64(GetBackgroundThreadNumRuns())
}),
prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: subsystem,
Name: "background_thread_run_interval",
}, func() float64 {
return float64(GetBackgroundThreadRunInterval())
}),
} {
r.MustRegister(c)
}
}