You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the user wants to mount the pprof handlers using a non-default mux, they must do this by manually enumerating all of the available profilers2. For example:
This experience could be made better for users by moving the logic in the init function into a separate method (with the mux as an argument), then invoking this within the default package init function.
seankhliao
changed the title
[feat] Extend net/http/pprof to support enabling on non-default ServeMux
proposal: net/http/pprof: function to register all profiles to a mux
Jan 10, 2025
User Story
mux
instances.net/http/pprof
on a specificmux
instance.net/http/pprof
does not provide an ergonomic interface for attaching the handlers to a specific mux.Current Options / Alternatives Considered
The
net/http/pprof
packageinit
function is the recommended path for enabling thepprof
handler.1 This method uses theDefaultServeMux
:go/src/net/http/pprof/pprof.go
Lines 95 to 105 in 46b576b
If the user wants to mount the
pprof
handlers using a non-default mux, they must do this by manually enumerating all of the available profilers2. For example:Proposal
This experience could be made better for users by moving the logic in the
init
function into a separate method (with themux
as an argument), then invoking this within the default package init function.Footnotes
https://pkg.go.dev/net/http/pprof#:~:text=To%20use%20pprof%2C%20link%20this%20package%20into%20your%20program%3A ↩
https://pkg.go.dev/net/http/pprof#:~:text=If%20you%20are%20not%20using%20DefaultServeMux%2C%20you%20will%20have%20to%20register%20handlers%20with%20the%20mux%20you%20are%20using. ↩
The text was updated successfully, but these errors were encountered: