Enable net/http/pprof handlers in pprof web UI.#943
Enable net/http/pprof handlers in pprof web UI.#943aalexand wants to merge 2 commits intogoogle:mainfrom
Conversation
This is so that pprof itself can be profiled when needed. Tested: started the web UI, collected /debug/pprof/heap and /debug/pprof/profile profiles.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #943 +/- ##
==========================================
- Coverage 66.89% 66.86% -0.03%
==========================================
Files 44 44
Lines 9849 9852 +3
==========================================
Hits 6588 6588
- Misses 2822 2825 +3
Partials 439 439 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| mux.Handle("/ui/", http.StripPrefix("/ui", handler)) | ||
| mux.Handle("/", redirectWithQuery("/ui", http.StatusTemporaryRedirect)) | ||
| // Enable self-profiling handlers if net/http/pprof is imported by the main | ||
| // program. |
There was a problem hiding this comment.
Are there going to be users who are unhappy about having this access point opened?
| mux.Handle("/", redirectWithQuery("/ui", http.StatusTemporaryRedirect)) | ||
| // Enable self-profiling handlers if net/http/pprof is imported by the main | ||
| // program. | ||
| mux.HandleFunc("/debug/pprof/", http.DefaultServeMux.ServeHTTP) |
There was a problem hiding this comment.
Should we apply the same auth checks (localhost etc.) that we apply to other handlers?
| "github.com/chzyer/readline" | ||
| "github.com/google/pprof/driver" | ||
|
|
||
| _ "net/http/pprof" // Enable profiling pprof itself in the web UI mode. |
There was a problem hiding this comment.
In the past I have wanted to profile startup performance itself. This approach does not allow profiling startup time. An alternative would be flags (separate ones will be needed for cpu and memory profiling).
Not sure how we exit cleanly though to allow the profile to be saved if we are using flags.
This is so that pprof itself can be profiled when needed.
Tested: started the web UI, collected /debug/pprof/heap and /debug/pprof/profile profiles.