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

Use timer helper

parent 37b44ff7
package proxyd
import (
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/log"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/rs/cors"
"io"
"io/ioutil"
"net/http"
"time"
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/log"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/rs/cors"
"io"
"io/ioutil"
"net/http"
)
var (
......@@ -175,9 +174,8 @@ func writeRPCError(w http.ResponseWriter, id *int, code int, msg string) {
func instrumentedHdlr(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
httpRequestsCtr.Inc()
start := time.Now()
timer := prometheus.NewTimer(httpRequestDurationSummary)
defer timer.ObserveDuration()
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