Files
multica/server/internal/profiling/server.go
T
aa6d0dadcf MUL-6390: expose Go pprof on a loopback port (#7200)
* 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]>
2026-08-19 15:09:47 +08:00

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.
}
}