Skip to content

Commit 2dfb24b

Browse files
committed
api: fix pprof-address usage
Adding the following line will install handlers under the /debug/pprof/ URL to download live profiles: ``` import _ "net/http/pprof" ``` see: https://golang.org/pkg/net/http/pprof/ https://golang.org/pkg/runtime/pprof/ Signed-off-by: Wang Long <long.wanglong@huawei.com>
1 parent 0686d5f commit 2dfb24b

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

api/http/pprof/pprof.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import (
44
// expvar init routine adds the "/debug/vars" handler
55
_ "expvar"
66
"net/http"
7-
"net/http/pprof"
7+
// net/http/pprof installs the "/debug/pprof/{block,heap,goroutine,threadcreate}" handler
8+
_ "net/http/pprof"
89

910
"github.com/Sirupsen/logrus"
1011
)
@@ -13,11 +14,6 @@ import (
1314
func Enable(address string) {
1415
http.Handle("/", http.RedirectHandler("/debug/pprof", http.StatusMovedPermanently))
1516

16-
http.Handle("/debug/pprof/block", pprof.Handler("block"))
17-
http.Handle("/debug/pprof/heap", pprof.Handler("heap"))
18-
http.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
19-
http.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
20-
2117
go http.ListenAndServe(address, nil)
2218
logrus.Debug("pprof listening in address %s", address)
2319
}

0 commit comments

Comments
 (0)