mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-15 03:36:33 +03:00
b31e7f1ea7
* Setup basic prom metrics endpoint * Use default prom handler to expose go runtime metrics
20 lines
436 B
Go
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)
|
|
}
|