-
Notifications
You must be signed in to change notification settings - Fork 482
/
metrics.go
63 lines (56 loc) · 2.15 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
//go:build linux
// the build tag is to avoid unnecessary compilation of symtab
package ebpf
import (
ebpfmetrics "github.com/grafana/pyroscope/ebpf/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
targetsActive prometheus.Gauge
profilingSessionsTotal prometheus.Counter
profilingSessionsFailingTotal prometheus.Counter
pprofsTotal *prometheus.CounterVec
pprofBytesTotal *prometheus.CounterVec
pprofSamplesTotal *prometheus.CounterVec
ebpfMetrics *ebpfmetrics.Metrics
}
func newMetrics(reg prometheus.Registerer) *metrics {
m := &metrics{
targetsActive: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "pyroscope_ebpf_active_targets",
Help: "Current number of active targets being tracked by the ebpf component",
}),
profilingSessionsTotal: prometheus.NewCounter(prometheus.CounterOpts{
Name: "pyroscope_ebpf_profiling_sessions_total",
Help: "Total number of profiling sessions started by the ebpf component",
}),
profilingSessionsFailingTotal: prometheus.NewCounter(prometheus.CounterOpts{
Name: "pyroscope_ebpf_profiling_sessions_failing_total",
Help: "Total number of profiling sessions failed to complete by the ebpf component",
}),
pprofsTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "pyroscope_ebpf_pprofs_total",
Help: "Total number of pprof profiles collected by the ebpf component",
}, []string{"service_name"}),
pprofBytesTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "pyroscope_ebpf_pprof_bytes_total",
Help: "Total number of pprof profiles collected by the ebpf component",
}, []string{"service_name"}),
pprofSamplesTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "pyroscope_ebpf_pprof_samples_total",
Help: "Total number of pprof profiles collected by the ebpf component",
}, []string{"service_name"}),
ebpfMetrics: ebpfmetrics.New(reg),
}
if reg != nil {
reg.MustRegister(
m.targetsActive,
m.profilingSessionsTotal,
m.profilingSessionsFailingTotal,
m.pprofsTotal,
m.pprofBytesTotal,
m.pprofSamplesTotal,
)
}
return m
}