Commit b0b46991 by Carl Bergquist Committed by GitHub

Metrics: Add gauge for requests currently in flight (#22168)

Add gauge for requests currently in flight.

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
parent 8d1bef37
......@@ -7,13 +7,32 @@ import (
"time"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/prometheus/client_golang/prometheus"
"gopkg.in/macaron.v1"
)
var (
httpRequestsInFlight prometheus.Gauge
)
func init() {
httpRequestsInFlight = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "http_request_in_flight",
Help: "A gauge of requests currently being served by Grafana.",
},
)
prometheus.MustRegister(httpRequestsInFlight)
}
// RequestMetrics is a middleware handler that instruments the request
func RequestMetrics(handler string) macaron.Handler {
return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) {
rw := res.(macaron.ResponseWriter)
now := time.Now()
httpRequestsInFlight.Inc()
defer httpRequestsInFlight.Dec()
c.Next()
status := rw.Status()
......
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