我有客户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)
}
Run Code Online (Sandbox Code Playgroud)
它不起作用:
go tool pprof http://localhost:8201/debug/pprof/profile
Run Code Online (Sandbox Code Playgroud)
返回错误:
Failed to fetch http://localhost:8201/debug/pprof/profile?seconds=30
Run Code Online (Sandbox Code Playgroud)
谢谢.
编辑:我认为问题是我重写默认的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))
}
Run Code Online (Sandbox Code Playgroud)
处理程序在我的代码中不起作用.
You set "WriteTimeout" less then profile write time.
on pprof.StartCPUProfile() execute, It already start write, see:
So http.WriteTimeout must be greater than profile write time.
Sorry for my poor English.
| 归档时间: |
|
| 查看次数: |
2247 次 |
| 最近记录: |