Skip to content

Commit c59d3f8

Browse files
committed
pprof routes
1 parent 09babb6 commit c59d3f8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

main.go

+25
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net"
77
"net/http"
8+
"net/http/pprof"
89
"sync"
910
"time"
1011
_ "time/tzdata"
@@ -290,6 +291,30 @@ func main() {
290291

291292
apiGroup.GET("/devices/all", GetDevices)
292293

294+
debugGroup := r.Group("/debug")
295+
pprofGroup := debugGroup.Group("/pprof")
296+
pprofGroup.GET("/cmdline", func(c *gin.Context) {
297+
pprof.Cmdline(c.Writer, c.Request)
298+
})
299+
pprofGroup.GET("/heap", func(c *gin.Context) {
300+
pprof.Index(c.Writer, c.Request)
301+
})
302+
pprofGroup.GET("/block", func(c *gin.Context) {
303+
pprof.Index(c.Writer, c.Request)
304+
})
305+
pprofGroup.GET("/mutex", func(c *gin.Context) {
306+
pprof.Index(c.Writer, c.Request)
307+
})
308+
pprofGroup.GET("/trace", func(c *gin.Context) {
309+
pprof.Trace(c.Writer, c.Request)
310+
})
311+
pprofGroup.GET("/profile", func(c *gin.Context) {
312+
pprof.Profile(c.Writer, c.Request)
313+
})
314+
pprofGroup.GET("/symbol", func(c *gin.Context) {
315+
pprof.Symbol(c.Writer, c.Request)
316+
})
317+
293318
srv := &http.Server{
294319
Addr: fmt.Sprintf(":%d", cfg.Port),
295320
Handler: r,

0 commit comments

Comments
 (0)