mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
25 lines
510 B
Go
25 lines
510 B
Go
package metrics
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
. "github.com/foomo/contentserver/logger"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func PrometheusHandler() http.Handler {
|
|
h := http.NewServeMux()
|
|
h.Handle("/metrics", promhttp.Handler())
|
|
return h
|
|
}
|
|
|
|
func RunPrometheusHandler(listener string) {
|
|
Log.Info("starting prometheus handler on",
|
|
zap.String("address", listener),
|
|
)
|
|
Log.Error("server failed: ",
|
|
zap.Error(http.ListenAndServe(listener, PrometheusHandler())),
|
|
)
|
|
}
|