added reusable pprof endpoints

This commit is contained in:
Evgeniy Kulikov 2020-03-03 13:35:06 +03:00
parent ad03a95feb
commit 50e74ee3a1
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -4,10 +4,16 @@ import (
"net/http/pprof" "net/http/pprof"
rtp "runtime/pprof" rtp "runtime/pprof"
"github.com/fasthttp/router"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttpadaptor" "github.com/valyala/fasthttp/fasthttpadaptor"
) )
func attachProfiler(r *router.Router) {
r.GET("/debug/pprof/", pprofHandler())
r.GET("/debug/pprof/:name", pprofHandler())
}
func pprofHandler() fasthttp.RequestHandler { func pprofHandler() fasthttp.RequestHandler {
items := rtp.Profiles() items := rtp.Profiles()