Skip to content

Commit

Permalink
Do not rename included packages
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Oct 16, 2022
1 parent 7fb385a commit af47b1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions benchmark/getpid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"unsafe"

bpf "github.com/aquasecurity/libbpfgo"
"github.com/aquasecurity/libbpfgo"
"github.com/cloudflare/ebpf_exporter/util"
)

Expand All @@ -21,11 +21,11 @@ func BenchmarkGetpidWithNoProbes(b *testing.B) {
}

func BenchmarkGetpidWithSimpleMap(b *testing.B) {
benchmarkWithProbe(b, "probes/simple.bpf.o")
benchmarkWithProbe(b, "probes/simple.libbpfgo.o")
}

func BenchmarkGetpidWithComplexMap(b *testing.B) {
benchmarkWithProbe(b, "probes/complex.bpf.o")
benchmarkWithProbe(b, "probes/complex.libbpfgo.o")
}

func benchmarkWithProbe(b *testing.B, text string) {
Expand Down Expand Up @@ -74,8 +74,8 @@ func benchmarkWithProbe(b *testing.B, text string) {
b.Logf("keys = %d, value = %d", keys, value)
}

func setupGetpidProbe(name string) (*bpf.Module, error) {
module, err := bpf.NewModuleFromFile(name)
func setupGetpidProbe(name string) (*libbpfgo.Module, error) {
module, err := libbpfgo.NewModuleFromFile(name)
if err != nil {
return nil, fmt.Errorf("error creating module from file %q: %v", name, err)
}
Expand Down
8 changes: 4 additions & 4 deletions exporter/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

bpf "github.com/aquasecurity/libbpfgo"
"github.com/aquasecurity/libbpfgo"
)

const progTagPrefix = "prog_tag:\t"
Expand All @@ -20,7 +20,7 @@ func mergedTags(dst map[string]string, src map[string]string) {
}

// attach attaches functions to tracing points in provided module
func attach(module *bpf.Module, kprobes, kretprobes, tracepoints, rawTracepoints map[string]string) (map[string]string, error) {
func attach(module *libbpfgo.Module, kprobes, kretprobes, tracepoints, rawTracepoints map[string]string) (map[string]string, error) {
tags := map[string]string{}

probes, err := attachSomething(module, kprobes, "kprobe")
Expand Down Expand Up @@ -51,7 +51,7 @@ func attach(module *bpf.Module, kprobes, kretprobes, tracepoints, rawTracepoints
}

// attachSomething attaches some kind of probes and returns program tags
func attachSomething(module *bpf.Module, probes map[string]string, key string) (map[string]string, error) {
func attachSomething(module *libbpfgo.Module, probes map[string]string, key string) (map[string]string, error) {
tags := map[string]string{}

for probe, progName := range probes {
Expand Down Expand Up @@ -90,7 +90,7 @@ func attachSomething(module *bpf.Module, probes map[string]string, key string) (
return tags, nil
}

func extractTag(prog *bpf.BPFProg) (string, error) {
func extractTag(prog *libbpfgo.BPFProg) (string, error) {
name := fmt.Sprintf("/proc/self/fdinfo/%d", prog.FileDescriptor())

file, err := os.Open(name)
Expand Down
16 changes: 8 additions & 8 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
"strings"
"unsafe"

bpf "github.com/aquasecurity/libbpfgo"
"github.com/aquasecurity/libbpfgo"
"github.com/cloudflare/ebpf_exporter/config"
"github.com/cloudflare/ebpf_exporter/decoder"
"github.com/cloudflare/ebpf_exporter/util"
perf "github.com/elastic/go-perf"
"github.com/elastic/go-perf"
"github.com/iovisor/gobpf/pkg/cpuonline"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -26,7 +26,7 @@ const prometheusNamespace = "ebpf_exporter"
// Exporter is a ebpf_exporter instance implementing prometheus.Collector
type Exporter struct {
config config.Config
modules map[string]*bpf.Module
modules map[string]*libbpfgo.Module
perfMapCollectors []*PerfMapSink
kaddrs map[string]uint64
enabledProgramsDesc *prometheus.Desc
Expand Down Expand Up @@ -59,7 +59,7 @@ func New(cfg config.Config) (*Exporter, error) {

return &Exporter{
config: cfg,
modules: map[string]*bpf.Module{},
modules: map[string]*libbpfgo.Module{},
kaddrs: map[string]uint64{},
enabledProgramsDesc: enabledProgramsDesc,
programInfoDesc: programInfoDesc,
Expand All @@ -76,8 +76,8 @@ func (e *Exporter) Attach(configPath string) error {
return fmt.Errorf("multiple programs with name %q", program.Name)
}

bpfProgPath := filepath.Join(configPath, fmt.Sprintf("%s.bpf.o", program.Name))
module, err := bpf.NewModuleFromFile(bpfProgPath)
bpfProgPath := filepath.Join(configPath, fmt.Sprintf("%s.libbpfgo.o", program.Name))
module, err := libbpfgo.NewModuleFromFile(bpfProgPath)
if err != nil {
return fmt.Errorf("error creating module from %q for program %q: %v", bpfProgPath, program.Name, err)
}
Expand Down Expand Up @@ -146,7 +146,7 @@ func (e *Exporter) Attach(configPath string) error {
return nil
}

func (e *Exporter) passKaddrs(module *bpf.Module, program config.Program) error {
func (e *Exporter) passKaddrs(module *libbpfgo.Module, program config.Program) error {
if len(e.kaddrs) == 0 {
if err := e.populateKaddrs(); err != nil {
return fmt.Errorf("error populating kaddrs: %v", err)
Expand Down Expand Up @@ -350,7 +350,7 @@ func (e *Exporter) collectHistograms(ch chan<- prometheus.Metric) {
}

// tableValues returns values in the requested table to be used in metircs
func (e *Exporter) tableValues(module *bpf.Module, tableName string, labels []config.Label) ([]metricValue, error) {
func (e *Exporter) tableValues(module *libbpfgo.Module, tableName string, labels []config.Label) ([]metricValue, error) {
values := []metricValue{}

table, err := module.GetMap(tableName)
Expand Down
4 changes: 2 additions & 2 deletions exporter/perf_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"time"

bpf "github.com/aquasecurity/libbpfgo"
"github.com/aquasecurity/libbpfgo"
"github.com/cloudflare/ebpf_exporter/config"
"github.com/cloudflare/ebpf_exporter/decoder"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -16,7 +16,7 @@ type PerfMapSink struct {
dropCounter prometheus.Counter
}

func NewPerfMapSink(decoders *decoder.Set, module *bpf.Module, counterConfig config.Counter) *PerfMapSink {
func NewPerfMapSink(decoders *decoder.Set, module *libbpfgo.Module, counterConfig config.Counter) *PerfMapSink {
var (
receiveCh = make(chan []byte)
lostCh = make(chan uint64)
Expand Down

0 comments on commit af47b1c

Please sign in to comment.