Add pprof
This commit is contained in:
parent
5da1eb2944
commit
56f77bb509
4 changed files with 27 additions and 1 deletions
5
Makefile
5
Makefile
|
@ -7,9 +7,12 @@ all: checkcalls
|
|||
go build -o gordio ${LDFLAGS} ./cmd/gordio/
|
||||
go build -o calls ${LDFLAGS} ./cmd/calls/
|
||||
|
||||
buildpprof:
|
||||
go build -o gordio-pprof ${LDFLAGS} -tags pprof ./cmd/gordio
|
||||
|
||||
clean:
|
||||
rm -rf client/calls/ && mkdir client/calls && touch client/calls/.gitkeep
|
||||
rm -f gordio calls
|
||||
rm -f gordio calls gordio-pprof
|
||||
|
||||
checkcalls:
|
||||
@test -e client/calls/index.html || make getcalls
|
||||
|
|
5
pkg/gordio/server/noprofile.go
Normal file
5
pkg/gordio/server/noprofile.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
// +build !pprof
|
||||
|
||||
package server
|
||||
|
||||
func (s *Server) installPprof() {}
|
16
pkg/gordio/server/profile.go
Normal file
16
pkg/gordio/server/profile.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
// +build pprof
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http/pprof"
|
||||
)
|
||||
|
||||
func (s *Server) installPprof() {
|
||||
r := s.r
|
||||
r.HandleFunc("/debug/pprof/", pprof.Index)
|
||||
r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
||||
r.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
||||
r.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
||||
r.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
||||
}
|
|
@ -28,6 +28,8 @@ func (s *Server) setupRoutes() {
|
|||
r := s.r
|
||||
r.Use(middleware.WithValue(database.DBCTXKeyValue, s.db))
|
||||
|
||||
s.installPprof()
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
// authenticated routes
|
||||
r.Use(s.auth.VerifyMiddleware(), s.auth.AuthMiddleware())
|
||||
|
|
Loading…
Reference in a new issue