I am trying to profile a go application and below is the code:
func main() {
defer pprof.StopCPUProfile()
f, err := os.Create("./profile.tar.gz")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
...
I am able to see the file was created on the disk once the application exits. Is there a way to flush the profile to disk without quitting the application? My application is a rest API which will keep running for a long time. I'd like to see profile file during the run time. I may create an internal rest path
in the application to flush profile data into file.