etcd-tester: add 'enable-pprof' option

release-3.1
Gyu-Ho Lee 2016-12-13 05:03:27 -08:00
parent 797d826117
commit 7d16e7d27e
No known key found for this signature in database
GPG Key ID: 1DDD39C7EB70C24C
1 changed files with 17 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import (
"flag"
"fmt"
"net/http"
"net/http/pprof"
"os"
"strings"
@ -34,6 +35,8 @@ const (
defaultFailpointPort = 2381
)
const pprofPrefix = "/debug/pprof-tester"
func main() {
endpointStr := flag.String("agent-endpoints", "localhost:9027", "HTTP RPC endpoints of agents. Do not specify the schema.")
clientPorts := flag.String("client-ports", "", "etcd client port for each agent endpoint")
@ -51,6 +54,7 @@ func main() {
stresserType := flag.String("stresser", "keys,lease", "comma separated list of stressers (keys, lease, v2keys, nop).")
failureTypes := flag.String("failures", "default,failpoints", "specify failures (concat of \"default\" and \"failpoints\").")
externalFailures := flag.String("external-failures", "", "specify a path of script for enabling/disabling an external fault injector")
enablePprof := flag.Bool("enable-pprof", false, "true to enable pprof")
flag.Parse()
eps := strings.Split(*endpointStr, ",")
@ -131,6 +135,19 @@ func main() {
sh := statusHandler{status: &t.status}
http.Handle("/status", sh)
http.Handle("/metrics", prometheus.Handler())
if *enablePprof {
http.Handle(pprofPrefix+"/", http.HandlerFunc(pprof.Index))
http.Handle(pprofPrefix+"/profile", http.HandlerFunc(pprof.Profile))
http.Handle(pprofPrefix+"/symbol", http.HandlerFunc(pprof.Symbol))
http.Handle(pprofPrefix+"/cmdline", http.HandlerFunc(pprof.Cmdline))
http.Handle(pprofPrefix+"/trace", http.HandlerFunc(pprof.Trace))
http.Handle(pprofPrefix+"/heap", pprof.Handler("heap"))
http.Handle(pprofPrefix+"/goroutine", pprof.Handler("goroutine"))
http.Handle(pprofPrefix+"/threadcreate", pprof.Handler("threadcreate"))
http.Handle(pprofPrefix+"/block", pprof.Handler("block"))
}
go func() { plog.Fatal(http.ListenAndServe(":9028", nil)) }()
t.runLoop()