我有一个客户的HTTP服务:
s := &http.Server{
Addr: config.Port,
Handler: Controller.Log(http.DefaultServeMux),
ReadTimeout: 3 * time.Second,
WriteTimeout: 3 * time.Second,
}
http.HandleFunc("/exapmle/router/", exampleFunc)
err := s.ListenAndServe()
if err != nil {
log.Critical(err)
os.Exit(1)
}
无法正常工作:
go tool pprof http://localhost:8201/debug/pprof/profile
返回错误:
Failed to fetch http://localhost:8201/debug/pprof/profile?seconds=30
感谢您的信任。以下是您需要翻译的内容:
谢谢。
编辑: 我认为问题出在我重写了默认的http服务器,net/http/pprof包注入了http处理程序:
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))
}
我的代码中处理程序不起作用。
import _ "net/http/pprof"
? - Charlie Andrews