forked from TrueCloudLab/neoneo-go
0085831ec5
Since we have some perf issues from time to time it is good to have pprof debugger. Disabled by default.
25 lines
685 B
Go
25 lines
685 B
Go
package metrics
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/pprof"
|
|
)
|
|
// PprofService https://golang.org/pkg/net/http/pprof/.
|
|
type PprofService Service
|
|
|
|
// NewPprofService created new service for gathering pprof metrics.
|
|
func NewPprofService(cfg Config) *Service {
|
|
handler := http.NewServeMux()
|
|
handler.HandleFunc("/debug/pprof", pprof.Index)
|
|
handler.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
|
|
handler.HandleFunc("/debug/pprof/profile", pprof.Profile)
|
|
handler.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
|
|
handler.HandleFunc("/debug/pprof/trace", pprof.Trace)
|
|
|
|
return &Service{
|
|
&http.Server{
|
|
Addr: cfg.Address + ":" + cfg.Port,
|
|
Handler: handler,
|
|
}, cfg, "Pprof",
|
|
}
|
|
}
|