Skip to content

Commit

Permalink
Fix Mac compilation (#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomac authored Jan 14, 2025
1 parent 02c626b commit 3baaf5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/export/prom/prom_bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cilium/ebpf"
"github.com/mariomac/pipes/pipe"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/unix"

"github.com/grafana/beyla/pkg/internal/connector"
"github.com/grafana/beyla/pkg/internal/pipe/global"
Expand Down Expand Up @@ -110,10 +109,7 @@ func (bc *BPFCollector) Collect(ch chan<- prometheus.Metric) {
}

func (bc *BPFCollector) collectProbesMetrics(ch chan<- prometheus.Metric) {
_, err := ebpf.EnableStats(unix.BPF_STATS_RUN_TIME)
if err != nil {
bc.log.Error("failed to enable runtime stats", "error", err)
}
bc.enableBPFStatsRuntime()

// Iterate over all eBPF programs
ids, err := ebpf.ProgramGetNextID(0)
Expand Down
13 changes: 13 additions & 0 deletions pkg/export/prom/prom_bpf_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package prom

import (
"github.com/cilium/ebpf"
"golang.org/x/sys/unix"
)

func (bc *BPFCollector) enableBPFStatsRuntime() {
_, err := ebpf.EnableStats(unix.BPF_STATS_RUN_TIME)
if err != nil {
bc.log.Error("failed to enable runtime stats", "error", err)
}
}
5 changes: 5 additions & 0 deletions pkg/export/prom/prom_bpf_nonlinux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !linux

package prom

func (bc *BPFCollector) enableBPFStatsRuntime() {}

0 comments on commit 3baaf5c

Please sign in to comment.