-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrace.go
43 lines (35 loc) · 1.16 KB
/
trace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package intake
import (
"net/http"
"net/http/pprof"
"github.com/julienschmidt/httprouter"
)
// AttachPprofTraceEndpoints attaches with index page for viewing
func (a *Intake) AttachPprofTraceEndpoints() {
a.Logger.Info("attaching debug pprof endpoints")
a.Router.Handler(http.MethodGet, "/debug/pprof/*item", http.DefaultServeMux)
}
// DebugTraceEndpoints follows the same middleware route pattern without the pprof
// index page
func DebugTraceEndpoints(mw ...MiddleWare) Endpoints {
endpoints := Endpoints{
GET("/debug/pprof/cmdline", DEBUGPProfCmdLine),
GET("/debug/pprof/profile", DEBUGPProfProfile),
GET("/debug/pprof/symbol", DEBUGPProfSymbol),
GET("/debug/pprof/trace", DEBUGPProfTrace),
}
endpoints.Use(mw...)
return endpoints
}
func DEBUGPProfCmdLine(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
pprof.Cmdline(w, r)
}
func DEBUGPProfProfile(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
pprof.Profile(w, r)
}
func DEBUGPProfSymbol(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
pprof.Symbol(w, r)
}
func DEBUGPProfTrace(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
pprof.Trace(w, r)
}