Prometheus metrics

This commit is contained in:
DarthSim
2018-10-29 18:04:47 +06:00
parent 8030e0aa27
commit dd85087e6a
129 changed files with 32503 additions and 5 deletions

View File

@@ -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"))
}