Setup basic prom metrics endpoint (#624)
* Setup basic prom metrics endpoint * Use default prom handler to expose go runtime metrics
This commit is contained in:
19
pkg/metrics/server.go
Normal file
19
pkg/metrics/server.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user