limit the number of requests in flights for Prometheus server (#1927)

* limit the number of requests in flights for Prometheus server

Closes #1804

Default to 1 because usually there's just one collector.

* config: Up default for prom connections
This commit is contained in:
Anton Kaliaev
2018-07-10 15:49:48 +04:00
committed by GitHub
parent ce33914f70
commit 4de9d42e4c
7 changed files with 35 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import (
"net"
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
amino "github.com/tendermint/go-amino"
@ -599,8 +600,13 @@ func (n *Node) startRPC() ([]net.Listener, error) {
// collectors on addr.
func (n *Node) startPrometheusServer(addr string) *http.Server {
srv := &http.Server{
Addr: addr,
Handler: promhttp.Handler(),
Addr: addr,
Handler: promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer, promhttp.HandlerFor(
prometheus.DefaultGatherer,
promhttp.HandlerOpts{MaxRequestsInFlight: n.config.Instrumentation.MaxOpenConnections},
),
),
}
go func() {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {