diff --git a/perf/collector_libpfm.go b/perf/collector_libpfm.go index 58a00dada5b..58e5bcae46d 100644 --- a/perf/collector_libpfm.go +++ b/perf/collector_libpfm.go @@ -199,7 +199,7 @@ func (c *collector) setup() error { leaderFileDescriptors, err := c.createLeaderFileDescriptors(group.events, cgroupFd, groupIndex, leaderFileDescriptors) if err != nil { - klog.Error(err) + klog.Errorf("Cannot count perf event group %v: %v", group.events, err) c.deleteGroup(groupIndex) continue } else { @@ -232,7 +232,7 @@ func (c *collector) createLeaderFileDescriptors(events []Event, cgroupFd int, gr config := c.createConfigFromRawEvent(customEvent) leaderFileDescriptors, err = c.registerEvent(eventInfo{string(customEvent.Name), config, cgroupFd, groupIndex, isGroupLeader}, leaderFileDescriptors) if err != nil { - return nil, fmt.Errorf("cannot to register perf event: %v", err) + return nil, fmt.Errorf("cannot register perf event: %v", err) } } else { config, err := c.createConfigFromEvent(event) @@ -242,7 +242,7 @@ func (c *collector) createLeaderFileDescriptors(events []Event, cgroupFd int, gr } leaderFileDescriptors, err = c.registerEvent(eventInfo{string(event), config, cgroupFd, groupIndex, isGroupLeader}, leaderFileDescriptors) if err != nil { - return nil, fmt.Errorf("cannot to register perf event: %v", err) + return nil, fmt.Errorf("cannot register perf event: %v", err) } // Clean memory allocated by C code. C.free(unsafe.Pointer(config)) diff --git a/perf/collector_libpfm_test.go b/perf/collector_libpfm_test.go index 7dbf09f2ed4..c1ef62a836f 100644 --- a/perf/collector_libpfm_test.go +++ b/perf/collector_libpfm_test.go @@ -27,8 +27,6 @@ import ( "golang.org/x/sys/unix" - "golang.org/x/sys/unix" - "github.com/stretchr/testify/assert" info "github.com/google/cadvisor/info/v1" diff --git a/perf/uncore_libpfm.go b/perf/uncore_libpfm.go index 64c50063e7d..18439478edc 100644 --- a/perf/uncore_libpfm.go +++ b/perf/uncore_libpfm.go @@ -467,6 +467,7 @@ func (c *uncoreCollector) setupRawEvent(event *CustomEvent, pmus uncorePMUs, gro return nil } + func (c *uncoreCollector) deleteGroup(groupIndex int) { groupPMUs := c.cpuFiles[groupIndex] for pmu, group := range groupPMUs {