pgweb/pkg/metrics/server.go
Dan Sosedoff b31e7f1ea7
Setup basic prom metrics endpoint (#624)
* Setup basic prom metrics endpoint
* Use default prom handler to expose go runtime metrics
2022-12-20 10:13:42 -06:00

20 lines
436 B
Go

package metrics
import (
"net/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
)
func Handler() http.Handler {
return promhttp.Handler()
}
func StartServer(logger *logrus.Logger, path string, addr string) error {
logger.WithField("addr", addr).WithField("path", path).Info("starting prometheus metrics server")
http.Handle(path, Handler())
return http.ListenAndServe(addr, nil)
}