我有一个现有的 http 服务器,我想对其进行分析。我已经包含_ "net/http/pprof"在我的导入中,并且我已经运行了 http 服务器:router := createRouter()server := &http.Server { Addr: ":8080", Handler: router, ReadTimeout: 15*time.Second, WriteTimeout: 15*time.Second,// MaxHeaderBytes: 4096,}log.Fatal(server.ListenAndServe())当我尝试访问http://localhost:8080/debug/pprof/我得到404 page not found.这就是我go tool pprof在本地机器上使用时得到的:userver@userver:~/Desktop/gotest$ go tool pprof http://192.168.0.27:8080/Use of uninitialized value $prefix in concatenation (.) or string at /usr/lib/go/pkg/tool/linux_amd64/pprof line 3019.Read http://192.168.0.27:8080/pprof/symbolFailed to get the number of symbols from http://192.168.0.27:8080/pprof/symboluserver@userver:~/Desktop/gotest$ go tool pprof http://localhost:8080/debug/pprof/profileRead http://localhost:8080/debug/pprof/symbolFailed to get the number of symbols from http://localhost:8080/debug/pprof/symbol远程客户端也一样:MacBookAir:~ apple$ go tool pprof http://192.168.0.27:8080/Use of uninitialized value $prefix in concatenation (.) or string at /usr/local/Cellar/go/1.3.2/libexec/pkg/tool/darwin_amd64/pprof line 3027.Read http://192.168.0.27:8080/pprof/symbolFailed to get the number of symbols from http://192.168.0.27:8080/pprof/symbol
3 回答
牛魔王的故事
TA贡献1830条经验 获得超3个赞
文档中没有明确提到它,net/http/pprof只是将其处理程序注册到http.DefaultServeMux.
从来源:
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))
http.Handle("/debug/pprof/trace", http.HandlerFunc(Trace))
}
如果您不使用默认多路复用器,则只需使用您正在使用的任何多路复用器注册您想要的任何/所有多路复用器,例如像mymux.HandleFunc("…", pprof.Index)等。
或者,您可以使用您显示的默认多路复用器侦听单独的端口(如果需要,也可能仅绑定到 localhost)。
- 3 回答
- 0 关注
- 252 浏览
添加回答
举报
0/150
提交
取消