A helper for using Go's pprof package with web applications. For now, it just prints out pseudocode.
go install github.com/stefafafan/pprof-helper
Go to the directory with go.mod
and call the helper. The helper will go through your go.mod
and for now just print out pseudocode that matches the used web framework.
$ cd your-go-project
$ pprof-helper
For goji, update the code like this:
import (
"net/http/pprof"
)
func main() {
mux := goji.NewMux()
mux.HandleFunc(pat.Get("/debug/pprof/"), pprof.Index)
mux.HandleFunc(pat.Get("/debug/pprof/cmdline"), pprof.Cmdline)
mux.HandleFunc(pat.Get("/debug/pprof/profile"), pprof.Profile)
mux.HandleFunc(pat.Get("/debug/pprof/symbol"), pprof.Symbol)
}
You can also specify --go-mod-file
option, which is the path of the go.mod
instead of moving to that directory.
$ pprof-helper --go-mod-file=./my-go-project/go.mod