mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-08 17:36:45 +08:00
* feat(server): expose loopback pprof endpoint Co-authored-by: multica-agent <[email protected]> * test(server): remove redundant profiling tests Co-authored-by: multica-agent <[email protected]> * feat(server): complete pprof diagnostics support Co-authored-by: multica-agent <[email protected]> * fix(server): keep pprof fixed and tool-compatible Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Sol-Boy <[email protected]> Co-authored-by: multica-agent <[email protected]>
32 lines
892 B
Go
32 lines
892 B
Go
package profiling
|
|
|
|
import (
|
|
"net/http"
|
|
httppprof "net/http/pprof"
|
|
"time"
|
|
)
|
|
|
|
const Addr = "127.0.0.1:6060"
|
|
|
|
func NewHandler() http.Handler {
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("GET /debug/pprof/", httppprof.Index)
|
|
mux.HandleFunc("GET /debug/pprof/cmdline", httppprof.Cmdline)
|
|
mux.HandleFunc("GET /debug/pprof/profile", httppprof.Profile)
|
|
mux.HandleFunc("GET /debug/pprof/symbol", httppprof.Symbol)
|
|
mux.HandleFunc("POST /debug/pprof/symbol", httppprof.Symbol)
|
|
mux.HandleFunc("GET /debug/pprof/trace", httppprof.Trace)
|
|
return mux
|
|
}
|
|
|
|
func NewServer() *http.Server {
|
|
return &http.Server{
|
|
Addr: Addr,
|
|
Handler: NewHandler(),
|
|
ReadHeaderTimeout: 5 * time.Second,
|
|
IdleTimeout: 30 * time.Second,
|
|
// CPU profiles and traces run for a caller-selected duration. Leave
|
|
// ReadTimeout and WriteTimeout unset so long captures are not truncated.
|
|
}
|
|
}
|