@@ -934,10 +934,12 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
934
934
}
935
935
936
936
if cgroups .IsCgroup2UnifiedMode () {
937
- perfCgroupPath := path .Join (fs2 .UnifiedMountpoint , containerName )
938
- cont .perfCollector , err = m .perfManager .GetCollector (perfCgroupPath )
939
- if err != nil {
940
- klog .Errorf ("Perf event metrics will not be available for container %q: %v" , containerName , err )
937
+ if m .includedMetrics .Has (container .PerfMetrics ) {
938
+ perfCgroupPath := path .Join (fs2 .UnifiedMountpoint , containerName )
939
+ cont .perfCollector , err = m .perfManager .GetCollector (perfCgroupPath )
940
+ if err != nil {
941
+ klog .Errorf ("Perf event metrics will not be available for container %q: %v" , containerName , err )
942
+ }
941
943
}
942
944
} else {
943
945
devicesCgroupPath , err := handler .GetCgroupPath ("devices" )
@@ -949,13 +951,15 @@ func (m *manager) createContainerLocked(containerName string, watchSource watche
949
951
klog .V (4 ).Infof ("GPU metrics may be unavailable/incomplete for container %s: %s" , cont .info .Name , err )
950
952
}
951
953
}
952
- perfCgroupPath , err := handler .GetCgroupPath ("perf_event" )
953
- if err != nil {
954
- klog .Warningf ("Error getting perf_event cgroup path: %q" , err )
955
- } else {
956
- cont .perfCollector , err = m .perfManager .GetCollector (perfCgroupPath )
954
+ if m .includedMetrics .Has (container .PerfMetrics ) {
955
+ perfCgroupPath , err := handler .GetCgroupPath ("perf_event" )
957
956
if err != nil {
958
- klog .Errorf ("Perf event metrics will not be available for container %q: %v" , containerName , err )
957
+ klog .Warningf ("Error getting perf_event cgroup path: %q" , err )
958
+ } else {
959
+ cont .perfCollector , err = m .perfManager .GetCollector (perfCgroupPath )
960
+ if err != nil {
961
+ klog .Errorf ("Perf event metrics will not be available for container %q: %v" , containerName , err )
962
+ }
959
963
}
960
964
}
961
965
}
0 commit comments