2019-03-07 16:14:57 +00:00
|
|
|
package prometheus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2022-06-13 22:29:26 +00:00
|
|
|
"time"
|
2019-03-07 16:14:57 +00:00
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RunSimpleServerOrDie is a blocking call to serve /metrics at the given
|
|
|
|
// address.
|
|
|
|
func RunSimpleServerOrDie(addr string) {
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
mux.Handle("/metrics", promhttp.Handler())
|
|
|
|
|
2022-06-13 22:29:26 +00:00
|
|
|
svr := &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: time.Second}
|
2019-06-12 23:58:49 +00:00
|
|
|
log.Fatal(svr.ListenAndServe())
|
2019-03-07 16:14:57 +00:00
|
|
|
}
|