Gin 开启pprof
在 gin 中开启pprof代码示例:
g := gin.New()
router := engine.Group("/debug/pprof")
{
router.GET("/", gin.WrapF(pprof.Index))
router.GET("/cmdline", gin.WrapF(pprof.Cmdline))
router.GET("/profile", gin.WrapF(pprof.Profile))
router.POST("/symbol", gin.WrapF(pprof.Symbol))
router.GET("/symbol", gin.WrapF(pprof.Symbol))
router.GET("/trace", gin.WrapF(pprof.Trace))
router.GET("/allocs", gin.WrapH(pprof.Handler("allocs")))
router.GET("/block", gin.WrapH(pprof.Handler("block")))
router.GET("/goroutine", gin.WrapH(pprof.Handler("goroutine")))
router.GET("/heap", gin.WrapH(pprof.Handler("heap")))
router.GET("/mutex", gin.WrapH(pprof.Handler("mutex")))
router.GET("/threadcreate", gin.WrapH(pprof.Handler("threadcreate")))
}
此外,可以引用 https://github.com/gin-contrib/pprof
包实现。