私は顧客の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))
}
私のコードではハンドラーが機能しません。