mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-24 20:36:24 +02:00
Add a metric "http_requests_in_flight"
This commit is contained in:
parent
ba76dfa3b2
commit
61346b9f4a
2 changed files with 12 additions and 1 deletions
|
|
@ -223,7 +223,12 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
timer := prometheus.NewTimer(metricRequestDuration)
|
||||
defer timer.ObserveDuration()
|
||||
metricRequestsInFlight.Inc()
|
||||
defer func() {
|
||||
timer.ObserveDuration()
|
||||
metricRequestsInFlight.Dec()
|
||||
}()
|
||||
|
||||
h.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ var (
|
|||
Name: "request_duration_seconds",
|
||||
Help: "Request response times",
|
||||
})
|
||||
metricRequestsInFlight = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "http",
|
||||
Name: "requests_in_flight",
|
||||
Help: "Number of requests in flight",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -36,4 +41,5 @@ func init() {
|
|||
prometheus.MustRegister(metricServedFromCache)
|
||||
prometheus.MustRegister(metricRemoteErrors)
|
||||
prometheus.MustRegister(metricRequestDuration)
|
||||
prometheus.MustRegister(metricRequestsInFlight)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue