2019-12-04 06:48:32 +00:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/pprof"
|
|
|
|
)
|
2019-12-17 11:51:07 +00:00
|
|
|
|
2019-12-04 06:48:32 +00:00
|
|
|
// 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()
|
2019-12-17 11:49:28 +00:00
|
|
|
handler.HandleFunc("/debug/pprof/", pprof.Index)
|
2019-12-04 06:48:32 +00:00
|
|
|
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",
|
|
|
|
}
|
|
|
|
}
|