keel/service/httppprof_pprof.go
Kevin Franklin Kim 07f0c394d5
feat: add GoRoutine service
moves all services into the service package
2023-09-08 12:17:23 +02:00

38 lines
821 B
Go

//go:build pprof
// +build pprof
package service
import (
"net/http"
"net/http/pprof"
"github.com/foomo/keel/log"
"go.uber.org/zap"
)
const (
DefaultHTTPPProfName = "pprof"
DefaultHTTPPProfAddr = "localhost:6060"
DefaultHTTPPProfPath = "/debug/pprof"
)
func NewHTTPPProf(l *zap.Logger, name, addr, path string) *ServiceHTTP {
handler := http.NewServeMux()
handler.HandleFunc(path+"/", pprof.Index)
handler.HandleFunc(path+"/cmdline", pprof.Cmdline)
handler.HandleFunc(path+"/profile", pprof.Profile)
handler.HandleFunc(path+"/symbol", pprof.Symbol)
handler.HandleFunc(path+"/trace", pprof.Trace)
return NewServiceHTTP(l, name, addr, handler)
}
func NewDefaultHTTPPProf() *ServiceHTTP {
return NewHTTPPProf(
log.Logger(),
DefaultHTTPPProfName,
DefaultHTTPPProfAddr,
DefaultHTTPPProfPath,
)
}