mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
28fff1b35e
# Background Erigon currently uses a combination of Victoria Metrics and Prometheus client for providing metrics. We want to rationalize this and use only the Prometheus client library, but we want to maintain the simplified Victoria Metrics methods for constructing metrics. This task is currently partly complete and needs to be finished to a stage where we can remove the Victoria Metrics module from the Erigon code base. # Summary of changes - Remove `UsePrometheusClient` boolean flag - Remove `VictoriaMetrics` client lib and related code (simplifies registry and prometheus http handler initialisation since now we have only 1 registry and can use default `promhttp.Handler`)
36 lines
948 B
Go
36 lines
948 B
Go
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/ledgerwatch/log/v3"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
)
|
|
|
|
var EnabledExpensive = false
|
|
|
|
// Setup starts a dedicated metrics server at the given address.
|
|
// This function enables metrics reporting separate from pprof.
|
|
func Setup(address string, logger log.Logger) *http.ServeMux {
|
|
prometheus.DefaultRegisterer.MustRegister(defaultSet)
|
|
|
|
prometheusMux := http.NewServeMux()
|
|
prometheusMux.Handle("/debug/metrics/prometheus", promhttp.Handler())
|
|
|
|
promServer := &http.Server{
|
|
Addr: address,
|
|
Handler: prometheusMux,
|
|
}
|
|
|
|
go func() {
|
|
if err := promServer.ListenAndServe(); err != nil {
|
|
logger.Error("Failure in running Prometheus server", "err", err)
|
|
}
|
|
}()
|
|
|
|
logger.Info("Enabling metrics export to prometheus", "path", fmt.Sprintf("http://%s/debug/metrics/prometheus", address))
|
|
return prometheusMux
|
|
}
|