mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Prometheus metrics
This commit is contained in:
11
server.go
11
server.go
@@ -203,6 +203,11 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
defer newRelicCancel()
|
||||
}
|
||||
|
||||
if prometheusEnabled {
|
||||
prometheusRequestsTotal.Inc()
|
||||
defer startPrometheusDuration(prometheusRequestDuration)()
|
||||
}
|
||||
|
||||
h.lock()
|
||||
defer h.unlock()
|
||||
|
||||
@@ -226,6 +231,9 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
if newRelicEnabled {
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
}
|
||||
if prometheusEnabled {
|
||||
incrementPrometheusErrorsTotal("download")
|
||||
}
|
||||
panic(newError(404, err.Error(), "Image is unreachable"))
|
||||
}
|
||||
|
||||
@@ -247,6 +255,9 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
if newRelicEnabled {
|
||||
sendErrorToNewRelic(ctx, err)
|
||||
}
|
||||
if prometheusEnabled {
|
||||
incrementPrometheusErrorsTotal("processing")
|
||||
}
|
||||
panic(newError(500, err.Error(), "Error occurred while processing image"))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user