Limit prometheus requests in flight, set timeout to reasonable 30 seconds (#8130)

This commit is contained in:
Preston Van Loon
2020-12-15 20:57:02 -08:00
committed by GitHub
parent 4326cbbf08
commit 3fb49433a1

View File

@@ -12,6 +12,7 @@ import (
"runtime/pprof"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prysmaticlabs/prysm/shared"
"github.com/prysmaticlabs/prysm/shared/logutil"
@@ -40,7 +41,10 @@ func NewService(addr string, svcRegistry *shared.ServiceRegistry, additionalHand
s := &Service{svcRegistry: svcRegistry}
mux := http.NewServeMux()
mux.Handle("/metrics", promhttp.Handler())
mux.Handle("/metrics", promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
MaxRequestsInFlight: 5,
Timeout: 30 * time.Second,
}))
mux.HandleFunc("/healthz", s.healthzHandler)
mux.HandleFunc("/goroutinez", s.goroutinezHandler)
mux.HandleFunc("/logs", logutil.NewLogStreamServer().Handler)