Merge pull request #31889 from cpuguy83/all_the_pprof

Use generic handler for pprof profile lookups
Upstream-commit: 022552ac873939db018722cb4a2e8289c6927e5e
Component: engine
This commit is contained in:
Vincent Demeester
2017-04-03 15:14:12 +02:00
committed by GitHub

View File

@ -19,10 +19,15 @@ func profilerSetup(mainRouter *mux.Router) {
r.HandleFunc("/pprof/profile", pprof.Profile)
r.HandleFunc("/pprof/symbol", pprof.Symbol)
r.HandleFunc("/pprof/trace", pprof.Trace)
r.HandleFunc("/pprof/block", pprof.Handler("block").ServeHTTP)
r.HandleFunc("/pprof/heap", pprof.Handler("heap").ServeHTTP)
r.HandleFunc("/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP)
r.HandleFunc("/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP)
r.HandleFunc("/pprof/{name}", handlePprof)
}
func handlePprof(w http.ResponseWriter, r *http.Request) {
var name string
if vars := mux.Vars(r); vars != nil {
name = vars["name"]
}
pprof.Handler(name).ServeHTTP(w, r)
}
// Replicated from expvar.go as not public.