|
|
@@ -21,6 +21,7 @@ import (
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
"net/http"
|
|
|
+ "net/http/pprof"
|
|
|
"net/url"
|
|
|
"path"
|
|
|
"strconv"
|
|
|
@@ -54,6 +55,7 @@ const (
|
|
|
healthPath = "/health"
|
|
|
versionPath = "/version"
|
|
|
configPath = "/config"
|
|
|
+ pprofPrefix = "/debug/pprof"
|
|
|
)
|
|
|
|
|
|
// NewClientHandler generates a muxed http.Handler with the given parameters to serve etcd client requests.
|
|
|
@@ -108,6 +110,23 @@ func NewClientHandler(server *etcdserver.EtcdServer, timeout time.Duration) http
|
|
|
mux.Handle(deprecatedMachinesPrefix, dmh)
|
|
|
handleAuth(mux, sech)
|
|
|
|
|
|
+ if server.IsPprofEnabled() {
|
|
|
+ plog.Infof("pprof is enabled under %s", pprofPrefix)
|
|
|
+
|
|
|
+ mux.HandleFunc(pprofPrefix, pprof.Index)
|
|
|
+ mux.HandleFunc(pprofPrefix+"/profile", pprof.Profile)
|
|
|
+ mux.HandleFunc(pprofPrefix+"/symbol", pprof.Symbol)
|
|
|
+ mux.HandleFunc(pprofPrefix+"/cmdline", pprof.Cmdline)
|
|
|
+ // TODO: currently, we don't create an entry for pprof.Trace,
|
|
|
+ // because go 1.4 doesn't provide it. After support of go 1.4 is dropped,
|
|
|
+ // we should add the entry.
|
|
|
+
|
|
|
+ mux.Handle(pprofPrefix+"/heap", pprof.Handler("heap"))
|
|
|
+ mux.Handle(pprofPrefix+"/goroutine", pprof.Handler("goroutine"))
|
|
|
+ mux.Handle(pprofPrefix+"/threadcreate", pprof.Handler("threadcreate"))
|
|
|
+ mux.Handle(pprofPrefix+"/block", pprof.Handler("block"))
|
|
|
+ }
|
|
|
+
|
|
|
return requestLogger(mux)
|
|
|
}
|
|
|
|