mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-20 20:43:09 -06:00
Only perform mediaapi metrics if enabled in config
This commit is contained in:
parent
33cdc5adb7
commit
a2be8ca873
|
|
@ -108,13 +108,16 @@ func makeDownloadAPI(
|
||||||
activeRemoteRequests *types.ActiveRemoteRequests,
|
activeRemoteRequests *types.ActiveRemoteRequests,
|
||||||
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
||||||
) http.HandlerFunc {
|
) http.HandlerFunc {
|
||||||
counterVec := promauto.NewCounterVec(
|
var counterVec *prometheus.CounterVec
|
||||||
prometheus.CounterOpts{
|
if cfg.Matrix.Metrics.Enabled {
|
||||||
Name: name,
|
counterVec = promauto.NewCounterVec(
|
||||||
Help: "Total number of media_api requests for either thumbnails or full downloads",
|
prometheus.CounterOpts{
|
||||||
},
|
Name: name,
|
||||||
[]string{"code"},
|
Help: "Total number of media_api requests for either thumbnails or full downloads",
|
||||||
)
|
},
|
||||||
|
[]string{"code"},
|
||||||
|
)
|
||||||
|
}
|
||||||
httpHandler := func(w http.ResponseWriter, req *http.Request) {
|
httpHandler := func(w http.ResponseWriter, req *http.Request) {
|
||||||
req = util.RequestWithLogging(req)
|
req = util.RequestWithLogging(req)
|
||||||
|
|
||||||
|
|
@ -166,5 +169,12 @@ func makeDownloadAPI(
|
||||||
vars["downloadName"],
|
vars["downloadName"],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return promhttp.InstrumentHandlerCounter(counterVec, http.HandlerFunc(httpHandler))
|
|
||||||
|
var handlerFunc http.HandlerFunc
|
||||||
|
if counterVec != nil {
|
||||||
|
handlerFunc = promhttp.InstrumentHandlerCounter(counterVec, http.HandlerFunc(httpHandler))
|
||||||
|
} else {
|
||||||
|
handlerFunc = http.HandlerFunc(httpHandler)
|
||||||
|
}
|
||||||
|
return handlerFunc
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue