mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 03:13:11 -06:00
Proper instrumenthandler fix
This commit is contained in:
parent
8f6ee9de9c
commit
f0e81464c1
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -80,13 +81,14 @@ func makeDownloadAPI(
|
||||||
activeRemoteRequests *types.ActiveRemoteRequests,
|
activeRemoteRequests *types.ActiveRemoteRequests,
|
||||||
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
||||||
) http.HandlerFunc {
|
) http.HandlerFunc {
|
||||||
handlerInfo := prometheus.NewCounterVec(
|
return promhttp.InstrumentHandlerCounter(
|
||||||
|
promauto.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Help: "Total number of media_api requests for either thumbnails or full downloads",
|
||||||
},
|
},
|
||||||
[]string{name},
|
[]string{"code"},
|
||||||
)
|
), http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
return promhttp.InstrumentHandlerCounter(handlerInfo, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
req = util.RequestWithLogging(req)
|
req = util.RequestWithLogging(req)
|
||||||
|
|
||||||
// Set common headers returned regardless of the outcome of the request
|
// Set common headers returned regardless of the outcome of the request
|
||||||
|
|
@ -107,5 +109,6 @@ func makeDownloadAPI(
|
||||||
activeThumbnailGeneration,
|
activeThumbnailGeneration,
|
||||||
name == "thumbnail",
|
name == "thumbnail",
|
||||||
)
|
)
|
||||||
}))
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue