Compare commits

...

1 Commits

Author SHA1 Message Date
William Banfield
f1dc3d2fea wip 2022-05-09 16:17:00 -04:00
2 changed files with 12 additions and 4 deletions

View File

@@ -489,7 +489,7 @@ func (n *nodeImpl) OnStart(ctx context.Context) error {
}
if n.config.Instrumentation.Prometheus && n.config.Instrumentation.PrometheusListenAddr != "" {
n.prometheusSrv = n.startPrometheusServer(ctx, n.config.Instrumentation.PrometheusListenAddr)
n.prometheusSrv = n.startPrometheusServer(ctx, registry, n.config.Instrumentation.PrometheusListenAddr)
}
// Start the transport.
@@ -572,12 +572,12 @@ func (n *nodeImpl) OnStop() {
// startPrometheusServer starts a Prometheus HTTP server, listening for metrics
// collectors on addr.
func (n *nodeImpl) startPrometheusServer(ctx context.Context, addr string) *http.Server {
func (n *nodeImpl) startPrometheusServer(ctx context.Context, registry *prometheus.Registry, addr string) *http.Server {
srv := &http.Server{
Addr: addr,
Handler: promhttp.InstrumentMetricHandler(
prometheus.DefaultRegisterer, promhttp.HandlerFor(
prometheus.DefaultGatherer,
registry, promhttp.HandlerFor(
registry,
promhttp.HandlerOpts{MaxRequestsInFlight: n.config.Instrumentation.MaxOpenConnections},
),
),

View File

@@ -8,6 +8,7 @@ import (
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
dbm "github.com/tendermint/tm-db"
abciclient "github.com/tendermint/tendermint/abci/client"
@@ -503,3 +504,10 @@ func createPrivval(ctx context.Context, logger log.Logger, conf *config.Config,
return defaultPV, nil
}
func createRegistry(conf *config.Config) *prometheus.Registry {
if conf.Instrumentation.Prometheus {
return prometheus.NewRegistry()
}
return prometheus.NewRegistry()
}