Open
Description
User Story
- I have an application that has
mux
instances. - I want to enable
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
package init
function is the recommended path for enabling the pprof
handler.1 This method uses the DefaultServeMux
:
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:
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline/", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile/", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol/", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace/", pprof.Trace)
Proposal
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.
Footnotes
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming