mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
8ea0096d56
This is a non functional change which consolidates the various packages under metrics into the top level package now that the dead code is removed. It is a precursor to the removal of Victoria metrics after which all erigon metrics code will be contained in this single package.
34 lines
900 B
Go
34 lines
900 B
Go
// Hook go-metrics into expvar
|
|
// on any /debug/metrics request, load all vars from the registry into expvar, and execute regular expvar handler
|
|
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
// 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 {
|
|
prometheusMux := http.NewServeMux()
|
|
|
|
prometheusMux.Handle("/debug/metrics/prometheus", Handler(DefaultRegistry))
|
|
|
|
promServer := &http.Server{
|
|
Addr: address,
|
|
Handler: prometheusMux,
|
|
}
|
|
|
|
go func() {
|
|
if err := promServer.ListenAndServe(); err != nil {
|
|
log.Error("Failure in running Prometheus server", "err", err)
|
|
}
|
|
}()
|
|
|
|
log.Info("Enabling metrics export to prometheus", "path", fmt.Sprintf("http://%s/debug/metrics/prometheus", address))
|
|
|
|
return prometheusMux
|
|
}
|