Skip to content

Commit

Permalink
pkg/debugutil: add 'mutex' profiler (Go 1.8+)
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Apr 18, 2017
1 parent 8fdf8f7 commit d0b6d01
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/debugutil/pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ package debugutil
import (
"net/http"
"net/http/pprof"
"runtime"
)

const HTTPPrefixPProf = "/debug/pprof"

func init() {
// 1 out of 5 mutex events are reported, on average
runtime.SetMutexProfileFraction(5)
}

// PProfHandlers returns a map of pprof handlers keyed by the HTTP path.
func PProfHandlers() map[string]http.Handler {
m := make(map[string]http.Handler)
Expand All @@ -34,6 +40,7 @@ func PProfHandlers() map[string]http.Handler {
m[HTTPPrefixPProf+"/goroutine"] = pprof.Handler("goroutine")
m[HTTPPrefixPProf+"/threadcreate"] = pprof.Handler("threadcreate")
m[HTTPPrefixPProf+"/block"] = pprof.Handler("block")
m[HTTPPrefixPProf+"/mutex"] = pprof.Handler("mutex")

return m
}

0 comments on commit d0b6d01

Please sign in to comment.