containerd/api/http/pprof/pprof.go
Kenfe-Mickaël Laventure 5624732128 Add golint to test (#255)
* Add a new lint rule to the Makefile

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Fix linter errors

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Allow replacing the default apt mirror

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-03 15:00:49 -07:00

23 lines
671 B
Go

package pprof
import (
// expvar init routine adds the "/debug/vars" handler
_ "expvar"
"net/http"
"net/http/pprof"
"github.com/Sirupsen/logrus"
)
// Enable registers the "/debug/pprof" handler
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)
}