Added prom metrics route

This commit is contained in:
Stephen McQuay 2018-01-21 13:57:31 -08:00
parent 2f0c01df7a
commit 6fa26ec095
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus/promhttp"
"mcquay.me/hwt"
pb "mcquay.me/hwt/rpc/hwt"
)
@ -16,7 +17,10 @@ func main() {
}
s := &hwt.Server{hn}
th := pb.NewHelloWorldServer(s, nil)
if err := http.ListenAndServe(":8080", th); err != nil {
sm := http.NewServeMux()
sm.Handle("/", th)
sm.Handle("/metrics", promhttp.Handler())
if err := http.ListenAndServe(":8080", sm); err != nil {
log.Fatalf("listen and serve: %v", err)
}
}