Adds request latency tracking

Fixes #1
This commit is contained in:
sm
2018-01-24 21:25:15 -08:00
parent 6fa26ec095
commit 70288014ea
4 changed files with 87 additions and 1 deletions
+9 -1
View File
@@ -6,7 +6,9 @@ import (
"os"
"github.com/prometheus/client_golang/prometheus/promhttp"
"mcquay.me/hwt"
"mcquay.me/hwt/metrics"
pb "mcquay.me/hwt/rpc/hwt"
)
@@ -15,8 +17,14 @@ func main() {
if err != nil {
log.Fatalf("cannot get hostname: %v", err)
}
if err := metrics.RegisterPromMetrics(); err != nil {
log.Fatalf("registering prom metrics: %v", err)
}
s := &hwt.Server{hn}
th := pb.NewHelloWorldServer(s, nil)
hs := hwt.NewMetricsHooks(metrics.HTTPLatency)
th := pb.NewHelloWorldServer(s, hs)
sm := http.NewServeMux()
sm.Handle("/", th)
sm.Handle("/metrics", promhttp.Handler())