profiling: Fix downloading tracing profiling data (#6599)

pkg/pprof saves tracing profiling data in a different file name
(trace.out) in contrary to other profiling mode.
master
Anis Elleuch 6 years ago committed by kannappanr
parent 5b3090dffc
commit 81a481e098
  1. 12
      cmd/utils.go

@ -218,18 +218,26 @@ func startProfiler(profilerType, dirPath string) (interface {
Stop()
}
// Enable profiler, supported types are [cpu, mem, block].
var profilerFileName string
// Enable profiler and set the name of the file that pkg/pprof
// library creates to store profiling data.
switch profilerType {
case "cpu":
profiler = profile.Start(profile.CPUProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
profilerFileName = "cpu.pprof"
case "mem":
profiler = profile.Start(profile.MemProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
profilerFileName = "mem.pprof"
case "block":
profiler = profile.Start(profile.BlockProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
profilerFileName = "block.pprof"
case "mutex":
profiler = profile.Start(profile.MutexProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
profilerFileName = "mutex.pprof"
case "trace":
profiler = profile.Start(profile.TraceProfile, profile.NoShutdownHook, profile.ProfilePath(dirPath))
profilerFileName = "trace.out"
default:
return nil, errors.New("profiler type unknown")
}
@ -237,7 +245,7 @@ func startProfiler(profilerType, dirPath string) (interface {
return &profilerWrapper{
stopFn: profiler.Stop,
pathFn: func() string {
return filepath.Join(dirPath, profilerType+".pprof")
return filepath.Join(dirPath, profilerFileName)
},
}, nil
}

Loading…
Cancel
Save