Register pprof handlers.

This commit is contained in:
Timo Reimann 2017-11-20 11:04:03 +01:00 committed by Traefiker
parent 05a9350e57
commit be306d651e
3 changed files with 14 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import (
"expvar" "expvar"
"fmt" "fmt"
"net/http" "net/http"
"net/http/pprof"
"runtime" "runtime"
"github.com/containous/mux" "github.com/containous/mux"
@ -36,4 +37,10 @@ func (g DebugHandler) AddRoutes(router *mux.Router) {
}) })
fmt.Fprint(w, "\n}\n") fmt.Fprint(w, "\n}\n")
}) })
router.Methods(http.MethodGet).PathPrefix("/debug/pprof/").HandlerFunc(pprof.Index)
router.Methods(http.MethodGet).PathPrefix("/debug/pprof/cmdline").HandlerFunc(pprof.Cmdline)
router.Methods(http.MethodGet).PathPrefix("/debug/pprof/profile").HandlerFunc(pprof.Profile)
router.Methods(http.MethodGet).PathPrefix("/debug/pprof/symbol").HandlerFunc(pprof.Symbol)
router.Methods(http.MethodGet).PathPrefix("/debug/pprof/trace").HandlerFunc(pprof.Trace)
} }

View file

@ -17,7 +17,10 @@
# #
dashboard = true dashboard = true
# Enabled debug mode # Enable debug mode.
# This will install HTTP handlers to expose Go expvars under /debug/vars and
# pprof profiling data under /debug/pprof.
# Additionally, the log level will be set to DEBUG.
# #
# Optional # Optional
# Default: false # Default: false

View file

@ -17,6 +17,9 @@
# graceTimeOut = "10s" # graceTimeOut = "10s"
# Enable debug mode. # Enable debug mode.
# This will install HTTP handlers to expose Go expvars under /debug/vars and
# pprof profiling data under /debug/pprof.
# Additionally, the log level will be set to DEBUG.
# #
# Optional # Optional
# Default: false # Default: false