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