Skip to content

Commit 9416996

Browse files
committed
api: fix pprof-address usage
those handlers already added by init functions Signed-off-by: Alexander Morozov <lk4d4@docker.com>
1 parent 9603417 commit 9416996

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

api/http/pprof/pprof.go

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package pprof
22

33
import (
4-
"expvar"
5-
"fmt"
4+
_ "expvar"
65
"net/http"
76
"net/http/pprof"
87

@@ -12,11 +11,6 @@ import (
1211
func Enable(address string) {
1312
http.Handle("/", http.RedirectHandler("/debug/pprof", http.StatusMovedPermanently))
1413

15-
http.Handle("/debug/vars", http.HandlerFunc(expVars))
16-
http.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
17-
http.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
18-
http.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
19-
http.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
2014
http.Handle("/debug/pprof/block", pprof.Handler("block"))
2115
http.Handle("/debug/pprof/heap", pprof.Handler("heap"))
2216
http.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
@@ -25,18 +19,3 @@ func Enable(address string) {
2519
go http.ListenAndServe(address, nil)
2620
logrus.Debug("pprof listening in address %s", address)
2721
}
28-
29-
// Replicated from expvar.go as not public.
30-
func expVars(w http.ResponseWriter, r *http.Request) {
31-
first := true
32-
w.Header().Set("Content-Type", "application/json; charset=utf-8")
33-
fmt.Fprintf(w, "{\n")
34-
expvar.Do(func(kv expvar.KeyValue) {
35-
if !first {
36-
fmt.Fprintf(w, ",\n")
37-
}
38-
first = false
39-
fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value)
40-
})
41-
fmt.Fprintf(w, "\n}\n")
42-
}

0 commit comments

Comments
 (0)