Commit 39dc46b4 authored by Matthew Slipper's avatar Matthew Slipper

Use timer helper

parent 37b44ff7
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"time"
) )
var ( var (
...@@ -175,9 +174,8 @@ func writeRPCError(w http.ResponseWriter, id *int, code int, msg string) { ...@@ -175,9 +174,8 @@ func writeRPCError(w http.ResponseWriter, id *int, code int, msg string) {
func instrumentedHdlr(h http.Handler) http.HandlerFunc { func instrumentedHdlr(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
httpRequestsCtr.Inc() httpRequestsCtr.Inc()
start := time.Now() timer := prometheus.NewTimer(httpRequestDurationSummary)
defer timer.ObserveDuration()
h.ServeHTTP(w, r) h.ServeHTTP(w, r)
dur := time.Since(start)
httpRequestDurationSummary.Observe(float64(dur) / float64(time.Second))
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment