Skip to content

Commit

Permalink
Init pprof explicitly (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored May 7, 2024
1 parent 0a7ccc3 commit 2de9dbd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions quesma/quesma/ui/console_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"mitmproxy/quesma/logger"
"mitmproxy/quesma/stats"
"net/http"
_ "net/http/pprof" // pprof is used for debugging
"net/http/pprof"
"runtime"
)

Expand All @@ -28,7 +28,7 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router {

router.HandleFunc(healthPath, qmc.checkHealth)

router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
qmc.initPprof(router)

router.HandleFunc("/", func(writer http.ResponseWriter, req *http.Request) {
buf := qmc.generateDashboard()
Expand Down Expand Up @@ -167,6 +167,14 @@ func (qmc *QuesmaManagementConsole) createRouting() *mux.Router {
return router
}

func (qmc *QuesmaManagementConsole) initPprof(router *mux.Router) {
router.HandleFunc("/debug/pprof/", pprof.Index)
router.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
router.HandleFunc("/debug/pprof/profile", pprof.Profile)
router.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
router.HandleFunc("/debug/pprof/trace", pprof.Trace)
}

func (qmc *QuesmaManagementConsole) newHTTPServer() *http.Server {
return &http.Server{
Addr: ":" + uiTcpPort,
Expand Down

0 comments on commit 2de9dbd

Please sign in to comment.