aboutsummaryrefslogtreecommitdiff
path: root/pprofhandler
diff options
context:
space:
mode:
authorGravatar mmta <memet.anwar@defenxor.com> 2018-09-29 15:38:12 +0700
committerGravatar Kirill Danshin <kirill@danshin.pro> 2018-10-03 18:15:43 +0300
commit33b80a5951ab04016906983ada65a0b31fb5ce57 (patch)
tree40129c296baabbb92b6dcc1e0d5c976365ee21d0 /pprofhandler
parentSupport Go modules (diff)
downloadfasthttp-33b80a5951ab04016906983ada65a0b31fb5ce57.tar.gz
fasthttp-33b80a5951ab04016906983ada65a0b31fb5ce57.tar.bz2
fasthttp-33b80a5951ab04016906983ada65a0b31fb5ce57.zip
Add support for named profiles like heap, goroutine, threadcreate, allocs, block, and mutex.
Diffstat (limited to 'pprofhandler')
-rw-r--r--pprofhandler/pprof.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pprofhandler/pprof.go b/pprofhandler/pprof.go
index 200ae51..c94d2c1 100644
--- a/pprofhandler/pprof.go
+++ b/pprofhandler/pprof.go
@@ -2,6 +2,7 @@ package pprofhandler
import (
"net/http/pprof"
+ rtp "runtime/pprof"
"strings"
"github.com/valyala/fasthttp"
@@ -30,6 +31,14 @@ func PprofHandler(ctx *fasthttp.RequestCtx) {
} else if strings.HasPrefix(string(ctx.Path()), "/debug/pprof/trace") {
trace(ctx)
} else {
+ for _, v := range rtp.Profiles() {
+ ppName := v.Name()
+ if strings.HasPrefix(string(ctx.Path()), "/debug/pprof/"+ppName) {
+ namedHandler := fasthttpadaptor.NewFastHTTPHandlerFunc(pprof.Handler(ppName).ServeHTTP)
+ namedHandler(ctx)
+ return
+ }
+ }
index(ctx)
}
}