package exporter import ( "net/http" "github.com/prometheus/client_golang/prometheus" ) type Middleware struct { metrics *Metrics } func (m Middleware) handler(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { timer := prometheus.NewTimer(m.metrics.metricRequestLatency) next.ServeHTTP(w, r) m.metrics.metricRequestsTotal.Inc() timer.ObserveDuration() }) }