mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 02:24:29 +00:00
436493350e
1. changes sentinel to use an http-like interface 2. moves hexutil, crypto/blake2b, metrics packages to erigon-lib
36 lines
936 B
Go
36 lines
936 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"
|
|
)
|
|
|
|
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 {
|
|
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 {
|
|
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
|
|
}
|