Refactor InstrumentHandlerCounter definition
parent
2baf5baa75
commit
9b5d6c9745
|
@ -85,14 +85,14 @@ func makeDownloadAPI(
|
||||||
activeRemoteRequests *types.ActiveRemoteRequests,
|
activeRemoteRequests *types.ActiveRemoteRequests,
|
||||||
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
activeThumbnailGeneration *types.ActiveThumbnailGeneration,
|
||||||
) http.HandlerFunc {
|
) http.HandlerFunc {
|
||||||
return promhttp.InstrumentHandlerCounter(
|
counterVec := promauto.NewCounterVec(
|
||||||
promauto.NewCounterVec(
|
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: name,
|
Name: name,
|
||||||
Help: "Total number of media_api requests for either thumbnails or full downloads",
|
Help: "Total number of media_api requests for either thumbnails or full downloads",
|
||||||
},
|
},
|
||||||
[]string{"code"},
|
[]string{"code"},
|
||||||
), http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
)
|
||||||
|
httpHandler := 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
|
||||||
|
@ -112,6 +112,6 @@ func makeDownloadAPI(
|
||||||
activeThumbnailGeneration,
|
activeThumbnailGeneration,
|
||||||
name == "thumbnail",
|
name == "thumbnail",
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
))
|
return promhttp.InstrumentHandlerCounter(counterVec, http.HandlerFunc(httpHandler))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue