2016-03-25 17:25:37 +00:00
|
|
|
package pprof
|
|
|
|
|
|
|
|
import (
|
2016-06-03 22:00:49 +00:00
|
|
|
// expvar init routine adds the "/debug/vars" handler
|
2016-04-04 18:55:17 +00:00
|
|
|
_ "expvar"
|
2016-03-25 17:25:37 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/pprof"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// Enable registers the "/debug/pprof" handler
|
2016-03-25 17:25:37 +00:00
|
|
|
func Enable(address string) {
|
|
|
|
http.Handle("/", http.RedirectHandler("/debug/pprof", http.StatusMovedPermanently))
|
|
|
|
|
|
|
|
http.Handle("/debug/pprof/block", pprof.Handler("block"))
|
|
|
|
http.Handle("/debug/pprof/heap", pprof.Handler("heap"))
|
|
|
|
http.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
|
|
|
|
http.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
|
|
|
|
|
|
|
|
go http.ListenAndServe(address, nil)
|
|
|
|
logrus.Debug("pprof listening in address %s", address)
|
|
|
|
}
|