Skip to content

Commit

Permalink
add wakeup count telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Dec 14, 2024
1 parent 51db2d7 commit 7ac0a0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ require (
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.59.1
github.com/DataDog/datadog-go/v5 v5.5.0
github.com/DataDog/datadog-operator v0.7.1-0.20241024104907-734366f3c0d1
github.com/DataDog/ebpf-manager v0.7.4
github.com/DataDog/ebpf-manager v0.7.5-0.20241213212949-6c446b204c82
github.com/DataDog/gopsutil v1.2.2
github.com/DataDog/nikos v1.12.8
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.22.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 20 additions & 8 deletions pkg/ebpf/telemetry/perf_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ var (
)

type perfUsageCollector struct {
mtx sync.Mutex
usage *prometheus.GaugeVec
usagePct *prometheus.GaugeVec
size *prometheus.GaugeVec
lost *prometheus.CounterVec
channelLen *prometheus.GaugeVec
mtx sync.Mutex
usage *prometheus.GaugeVec
usagePct *prometheus.GaugeVec
size *prometheus.GaugeVec
lost *prometheus.CounterVec
channelLen *prometheus.GaugeVec
wakeupCount *prometheus.CounterVec

perfMaps []*manager.PerfMap
perfChannelLenFuncs map[*manager.PerfMap]func() int
Expand Down Expand Up @@ -81,6 +82,14 @@ func NewPerfUsageCollector() prometheus.Collector {
},
[]string{"map_name", "map_type"},
),
wakeupCount: prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: "ebpf__perf",
Name: "_wakeup_count",
Help: "counter tracking number of times reader was woken up",
},
[]string{"map_name", "map_type"},
),
}
return perfCollector
}
Expand All @@ -101,7 +110,7 @@ func (p *perfUsageCollector) Collect(metrics chan<- prometheus.Metric) {
for _, pm := range p.perfMaps {
mapName, mapType := pm.Name, ebpf.PerfEventArray.String()
size := float64(pm.BufferSize())
usage, lost := pm.Telemetry()
usage, lost, wakeupCount := pm.Telemetry()
if usage == nil || lost == nil {
continue
}
Expand All @@ -115,6 +124,7 @@ func (p *perfUsageCollector) Collect(metrics chan<- prometheus.Metric) {
p.size.WithLabelValues(mapName, mapType, cpuString).Set(size)
p.lost.WithLabelValues(mapName, mapType, cpuString).Add(float64(lost[cpu]))
}
p.wakeupCount.WithLabelValues(mapName, mapType).Add(float64(wakeupCount))
}

for pm, chFunc := range p.perfChannelLenFuncs {
Expand All @@ -125,7 +135,7 @@ func (p *perfUsageCollector) Collect(metrics chan<- prometheus.Metric) {
for _, rb := range p.ringBuffers {
mapName, mapType := rb.Name, ebpf.RingBuf.String()
size := float64(rb.BufferSize())
usage, ok := rb.Telemetry()
usage, wakeupCount, ok := rb.Telemetry()
if !ok {
continue
}
Expand All @@ -135,6 +145,7 @@ func (p *perfUsageCollector) Collect(metrics chan<- prometheus.Metric) {
p.usage.WithLabelValues(mapName, mapType, cpuString).Set(count)
p.usagePct.WithLabelValues(mapName, mapType, cpuString).Set(100 * (count / size))
p.size.WithLabelValues(mapName, mapType, cpuString).Set(size)
p.wakeupCount.WithLabelValues(mapName, mapType).Add(float64(wakeupCount))
}

for rb, chFunc := range p.ringChannelLenFuncs {
Expand All @@ -147,6 +158,7 @@ func (p *perfUsageCollector) Collect(metrics chan<- prometheus.Metric) {
p.size.Collect(metrics)
p.lost.Collect(metrics)
p.channelLen.Collect(metrics)
p.wakeupCount.Collect(metrics)
}

// ReportPerfMapTelemetry starts reporting the telemetry for the provided PerfMap
Expand Down

0 comments on commit 7ac0a0d

Please sign in to comment.