mirror of https://github.com/docker/docs.git
Merge pull request #2818 from pnasrat/docker-pprof
Wire in pprof handlers.
This commit is contained in:
commit
3faf450f11
15
api.go
15
api.go
|
@ -15,6 +15,7 @@ import (
|
||||||
"mime"
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -1037,9 +1038,21 @@ func makeHttpHandler(srv *Server, logging bool, localMethod string, localRoute s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AttachProfiler(router *mux.Router) {
|
||||||
|
router.HandleFunc("/debug/pprof/", pprof.Index)
|
||||||
|
router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||||
|
router.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||||
|
router.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||||
|
router.HandleFunc("/debug/pprof/heap", pprof.Handler("heap").ServeHTTP)
|
||||||
|
router.HandleFunc("/debug/pprof/goroutine", pprof.Handler("goroutine").ServeHTTP)
|
||||||
|
router.HandleFunc("/debug/pprof/threadcreate", pprof.Handler("threadcreate").ServeHTTP)
|
||||||
|
}
|
||||||
|
|
||||||
func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
if os.Getenv("DEBUG") != "" {
|
||||||
|
AttachProfiler(r)
|
||||||
|
}
|
||||||
m := map[string]map[string]HttpApiFunc{
|
m := map[string]map[string]HttpApiFunc{
|
||||||
"GET": {
|
"GET": {
|
||||||
"/events": getEvents,
|
"/events": getEvents,
|
||||||
|
|
Loading…
Reference in New Issue