44package perf
55
66import (
7+ "fmt"
8+
79 "go.uber.org/multierr"
810 "golang.org/x/sys/unix"
911)
@@ -20,63 +22,72 @@ func NewSoftwareProfiler(pid, cpu int, opts ...int) (SoftwareProfiler, error) {
2022
2123 cpuClockProfiler , err := NewCPUClockProfiler (pid , cpu , opts ... )
2224 if err != nil {
23- e = multierr .Append (e , err )
25+ e = multierr .Append (e ,
26+ fmt .Errorf ("Failed to setup CPU clock profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
2427 } else {
2528 profilers [unix .PERF_COUNT_SW_CPU_CLOCK ] = cpuClockProfiler
2629 }
2730
2831 taskClockProfiler , err := NewTaskClockProfiler (pid , cpu , opts ... )
2932 if err != nil {
30- e = multierr .Append (e , err )
33+ e = multierr .Append (e ,
34+ fmt .Errorf ("Failed to setup task clock profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
3135 } else {
3236 profilers [unix .PERF_COUNT_SW_TASK_CLOCK ] = taskClockProfiler
3337 }
3438
3539 pageFaultProfiler , err := NewPageFaultProfiler (pid , cpu , opts ... )
3640 if err != nil {
37- e = multierr .Append (e , err )
41+ e = multierr .Append (e ,
42+ fmt .Errorf ("Failed to setup page fault profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
3843 } else {
3944 profilers [unix .PERF_COUNT_SW_PAGE_FAULTS ] = pageFaultProfiler
4045 }
4146
4247 ctxSwitchesProfiler , err := NewCtxSwitchesProfiler (pid , cpu , opts ... )
4348 if err != nil {
44- e = multierr .Append (e , err )
49+ e = multierr .Append (e ,
50+ fmt .Errorf ("Failed to setup context switch profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
4551 } else {
4652 profilers [unix .PERF_COUNT_SW_CONTEXT_SWITCHES ] = ctxSwitchesProfiler
4753 }
4854
4955 cpuMigrationsProfiler , err := NewCPUMigrationsProfiler (pid , cpu , opts ... )
5056 if err != nil {
51- e = multierr .Append (e , err )
57+ e = multierr .Append (e ,
58+ fmt .Errorf ("Failed to setup cpu migration profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
5259 } else {
5360 profilers [unix .PERF_COUNT_SW_CPU_MIGRATIONS ] = cpuMigrationsProfiler
5461 }
5562
5663 minorFaultProfiler , err := NewMinorFaultsProfiler (pid , cpu , opts ... )
5764 if err != nil {
58- e = multierr .Append (e , err )
65+ e = multierr .Append (e ,
66+ fmt .Errorf ("Failed to setup minor fault profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
5967 } else {
6068 profilers [unix .PERF_COUNT_SW_PAGE_FAULTS_MIN ] = minorFaultProfiler
6169 }
6270
6371 majorFaultProfiler , err := NewMajorFaultsProfiler (pid , cpu , opts ... )
6472 if err != nil {
65- e = multierr .Append (e , err )
73+ e = multierr .Append (e ,
74+ fmt .Errorf ("Failed to setup major fault profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
6675 } else {
6776 profilers [unix .PERF_COUNT_SW_PAGE_FAULTS_MAJ ] = majorFaultProfiler
6877 }
6978
7079 alignFaultsFrontProfiler , err := NewAlignFaultsProfiler (pid , cpu , opts ... )
7180 if err != nil {
72- e = multierr .Append (e , err )
81+ e = multierr .Append (e ,
82+ fmt .Errorf ("Failed to setup alignment fault profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
7383 } else {
7484 profilers [unix .PERF_COUNT_SW_ALIGNMENT_FAULTS ] = alignFaultsFrontProfiler
7585 }
7686
7787 emuFaultProfiler , err := NewEmulationFaultsProfiler (pid , cpu , opts ... )
7888 if err != nil {
79- e = multierr .Append (e , err )
89+ e = multierr .Append (e ,
90+ fmt .Errorf ("Failed to setup emulation fault profiler: pid (%d) cpu (%d) %q" , pid , cpu , err ))
8091 } else {
8192 profilers [unix .PERF_COUNT_SW_EMULATION_FAULTS ] = emuFaultProfiler
8293 }
0 commit comments