TUN-3773: Add back pprof endpoints

This commit is contained in:
Nuno Diegues 2021-01-19 11:53:54 +00:00
parent 2d0b86f2e4
commit a129572749
1 changed files with 10 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog" "github.com/rs/zerolog"
@ -21,16 +22,19 @@ const (
startupTime = time.Millisecond * 500 startupTime = time.Millisecond * 500
) )
func newMetricsHandler(readyServer *ReadyServer) *http.ServeMux { func newMetricsHandler(readyServer *ReadyServer) *mux.Router {
mux := http.NewServeMux() router := mux.NewRouter()
mux.Handle("/metrics", promhttp.Handler()) router.PathPrefix("/debug/").Handler(http.DefaultServeMux)
mux.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
router.Handle("/metrics", promhttp.Handler())
router.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintf(w, "OK\n") _, _ = fmt.Fprintf(w, "OK\n")
}) })
if readyServer != nil { if readyServer != nil {
mux.Handle("/ready", readyServer) router.Handle("/ready", readyServer)
} }
return mux
return router
} }
func ServeMetrics( func ServeMetrics(