plugin/pprof - add option to enable block profiling (#2729)

* - add an option for block profiling to plugin pprof

* - move option block into nested block
This commit is contained in:
Francois Tur
2019-03-29 02:37:17 -04:00
committed by Miek Gieben
parent f6eb2a4c14
commit c144da2524
4 changed files with 53 additions and 11 deletions

View File

@@ -6,12 +6,14 @@ import (
"net"
"net/http"
pp "net/http/pprof"
"runtime"
)
type handler struct {
addr string
ln net.Listener
mux *http.ServeMux
addr string
rateBloc int
ln net.Listener
mux *http.ServeMux
}
func (h *handler) Startup() error {
@@ -30,6 +32,8 @@ func (h *handler) Startup() error {
h.mux.HandleFunc(path+"/symbol", pp.Symbol)
h.mux.HandleFunc(path+"/trace", pp.Trace)
runtime.SetBlockProfileRate(h.rateBloc)
go func() {
http.Serve(h.ln, h.mux)
}()