mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
40 lines
938 B
Go
40 lines
938 B
Go
//go:build !pprof
|
|
|
|
package service
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"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) *HTTP {
|
|
route := func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusNotImplemented)
|
|
_, _ = w.Write([]byte("To enable pprof, you need to build your binary with the `-tags=pprof` flag"))
|
|
}
|
|
handler := http.NewServeMux()
|
|
handler.HandleFunc(path+"/", route)
|
|
handler.HandleFunc(path+"/cmdline", route)
|
|
handler.HandleFunc(path+"/profile", route)
|
|
handler.HandleFunc(path+"/symbol", route)
|
|
handler.HandleFunc(path+"/trace", route)
|
|
return NewHTTP(l, name, addr, handler)
|
|
}
|
|
|
|
func NewDefaultHTTPPProf() *HTTP {
|
|
return NewHTTPPProf(
|
|
log.Logger(),
|
|
DefaultHTTPPProfName,
|
|
DefaultHTTPPProfAddr,
|
|
DefaultHTTPPProfPath,
|
|
)
|
|
}
|