mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
committed by
Raul Jordan
parent
d23ba8e69d
commit
90b2a880c6
@@ -24,9 +24,15 @@ type Service struct {
|
||||
failStatus error
|
||||
}
|
||||
|
||||
// Handler represents a path and handler func to serve on the same port as /metrics, /healthz, /goroutinez, etc.
|
||||
type Handler struct {
|
||||
Path string
|
||||
Handler func(http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
// NewPrometheusService sets up a new instance for a given address host:port.
|
||||
// An empty host will match with any IP so an address like ":2121" is perfectly acceptable.
|
||||
func NewPrometheusService(addr string, svcRegistry *shared.ServiceRegistry) *Service {
|
||||
func NewPrometheusService(addr string, svcRegistry *shared.ServiceRegistry, additionalHandlers ...Handler) *Service {
|
||||
s := &Service{svcRegistry: svcRegistry}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
@@ -34,6 +40,11 @@ func NewPrometheusService(addr string, svcRegistry *shared.ServiceRegistry) *Ser
|
||||
mux.HandleFunc("/healthz", s.healthzHandler)
|
||||
mux.HandleFunc("/goroutinez", s.goroutinezHandler)
|
||||
|
||||
// Register additional handlers.
|
||||
for _, h := range additionalHandlers {
|
||||
mux.HandleFunc(h.Path, h.Handler)
|
||||
}
|
||||
|
||||
s.server = &http.Server{Addr: addr, Handler: mux}
|
||||
|
||||
return s
|
||||
|
||||
Reference in New Issue
Block a user