From 400b2fdd3f1eeeb90061275df9b47ff1d4abe380 Mon Sep 17 00:00:00 2001 From: dmathieu <42@dmathieu.com> Date: Wed, 20 Nov 2024 14:59:37 +0100 Subject: [PATCH] move lookupcgroupv2 to libpf --- {util/cgroup => libpf}/cgroupv2.go | 5 ++--- reporter/otlp_reporter.go | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) rename {util/cgroup => libpf}/cgroupv2.go (86%) diff --git a/util/cgroup/cgroupv2.go b/libpf/cgroupv2.go similarity index 86% rename from util/cgroup/cgroupv2.go rename to libpf/cgroupv2.go index 5026ec87..aa5d952f 100644 --- a/util/cgroup/cgroupv2.go +++ b/libpf/cgroupv2.go @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -package cgroup // import "go.opentelemetry.io/ebpf-profiler/util/cgroup" +package libpf // import "go.opentelemetry.io/ebpf-profiler/libpf" import ( "bufio" @@ -11,7 +11,6 @@ import ( lru "github.com/elastic/go-freelru" log "github.com/sirupsen/logrus" - "go.opentelemetry.io/ebpf-profiler/libpf" ) var ( @@ -19,7 +18,7 @@ var ( ) // LookupCgroupv2 returns the cgroupv2 ID for pid. -func LookupCgroupv2(cgrouplru *lru.SyncedLRU[libpf.PID, string], pid libpf.PID) (string, error) { +func LookupCgroupv2(cgrouplru *lru.SyncedLRU[PID, string], pid PID) (string, error) { id, ok := cgrouplru.Get(pid) if ok { return id, nil diff --git a/reporter/otlp_reporter.go b/reporter/otlp_reporter.go index 57f01658..ec92eca7 100644 --- a/reporter/otlp_reporter.go +++ b/reporter/otlp_reporter.go @@ -27,7 +27,6 @@ import ( "go.opentelemetry.io/ebpf-profiler/libpf" "go.opentelemetry.io/ebpf-profiler/libpf/xsync" - "go.opentelemetry.io/ebpf-profiler/util/cgroup" ) // Assert that we implement the full Reporter interface. @@ -209,7 +208,7 @@ func (r *OTLPReporter) ReportTraceEvent(trace *libpf.Trace, meta *TraceEventMeta traceEventsMap := r.traceEvents.WLock() defer r.traceEvents.WUnlock(&traceEventsMap) - containerID, err := cgroup.LookupCgroupv2(r.cgroupv2ID, meta.PID) + containerID, err := libpf.LookupCgroupv2(r.cgroupv2ID, meta.PID) if err != nil { log.Debugf("Failed to get a cgroupv2 ID as container ID for PID %d: %v", meta.PID, err)