Skip to content

Commit

Permalink
feat(debug): optional pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
kpetremann committed Nov 5, 2024
1 parent 3e541e2 commit 9e121f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/api/router/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ func (m *Manager) ListenAndServe(ctx context.Context, address string, port int,
mux.HandleFunc("GET /debug/pprof/symbol", pprof.Symbol)
}

if enablepprof {
router.HandlerFunc(http.MethodGet, "/debug/pprof/", pprof.Index)
router.HandlerFunc(http.MethodGet, "/debug/pprof/allocs", pprof.Index)
router.HandlerFunc(http.MethodGet, "/debug/pprof/goroutine", pprof.Index)
router.HandlerFunc(http.MethodGet, "/debug/pprof/heap", pprof.Index)
router.HandlerFunc(http.MethodGet, "/debug/pprof/profile", pprof.Profile)
router.HandlerFunc(http.MethodGet, "/debug/pprof/trace", pprof.Trace)
router.HandlerFunc(http.MethodGet, "/debug/pprof/symbol", pprof.Symbol)
}

listenSocket := fmt.Sprint(address, ":", port)
log.Info().Msgf("Start webserver - listening on %s", listenSocket)

Expand Down
5 changes: 5 additions & 0 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type Config struct {
Level string
Pretty bool
}
Debug struct {

Check failure on line 44 in internal/config/settings.go

View workflow job for this annotation

GitHub Actions / goreleaser

other declaration of Debug
Pprof struct {
Enabled bool
}
}
Datacenter string
API struct {
ListenAddress string
Expand Down

0 comments on commit 9e121f9

Please sign in to comment.