From 81a481e098f257fea0abf44db24fe89a6a0e7230 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Mon, 15 Oct 2018 19:13:19 +0100 Subject: [PATCH] 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. --- cmd/utils.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/utils.go b/cmd/utils.go index e064dd0b3..81117a356 100644 --- a/cmd/utils.go +++ b/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 }