gorilla - Can't use go tool pprof with an existing server -
i have existing http server profile. have included _ "net/http/pprof"
to imports, , have http server running:
router := createrouter() server := &http.server { addr: ":8080", handler: router, readtimeout: 15*time.second, writetimeout: 15*time.second, // maxheaderbytes: 4096, } log.fatal(server.listenandserve())
when i'm trying access http://localhost:8080/debug/pprof/ 404 page not found
.
that's when using go tool pprof
on local machine:
userver@userver:~/desktop/gotest$ go tool pprof http://192.168.0.27:8080/ use of uninitialized value $prefix in concatenation (.) or string @ /usr/lib/go/pkg/tool/linux_amd64/pprof line 3019. read http://192.168.0.27:8080/pprof/symbol failed number of symbols http://192.168.0.27:8080/pprof/symbol userver@userver:~/desktop/gotest$ go tool pprof http://localhost:8080/debug/pprof/profile read http://localhost:8080/debug/pprof/symbol failed number of symbols http://localhost:8080/debug/pprof/symbol
same remote client:
macbookair:~ apple$ go tool pprof http://192.168.0.27:8080/ use of uninitialized value $prefix in concatenation (.) or string @ /usr/local/cellar/go/1.3.2/libexec/pkg/tool/darwin_amd64/pprof line 3027. read http://192.168.0.27:8080/pprof/symbol failed number of symbols http://192.168.0.27:8080/pprof/symbol
it's not explicitly mentioned in documentation, net/http/pprof
registers handlers http.defaultservemux
.
from source:
func init() { http.handle("/debug/pprof/", http.handlerfunc(index)) http.handle("/debug/pprof/cmdline", http.handlerfunc(cmdline)) http.handle("/debug/pprof/profile", http.handlerfunc(profile)) http.handle("/debug/pprof/symbol", http.handlerfunc(symbol)) }
if you're not using default mux have register any/all of want whatever mux you're using, e.g. something mymux.handlefunc("…", pprof.index)
, etc.
alternatively can listen on separate port (also possibly bound localhost if desired) default mux you've shown.
Comments
Post a Comment