mirror of
https://github.com/sosedoff/pgweb.git
synced 2024-12-15 20:13:06 +03:00
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)
|
||
|
}
|