From 081b636bc57f2b92922c02797f73b11381f0c0b3 Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Fri, 24 Nov 2023 10:36:52 -0800 Subject: [PATCH] increment errors in response to callback/copy failures --- zipserver/copy_handler.go | 2 ++ zipserver/extract_handler.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/zipserver/copy_handler.go b/zipserver/copy_handler.go index f9418c9..01978e9 100644 --- a/zipserver/copy_handler.go +++ b/zipserver/copy_handler.go @@ -31,6 +31,8 @@ func notifyCallback(callbackURL string, resValues url.Values) error { notifyCtx, notifyCancel := context.WithTimeout(context.Background(), time.Duration(globalConfig.AsyncNotificationTimeout)) defer notifyCancel() + globalMetrics.TotalErrors.Add(1) + outBody := bytes.NewBufferString(resValues.Encode()) req, err := http.NewRequestWithContext(notifyCtx, http.MethodPost, callbackURL, outBody) if err != nil { diff --git a/zipserver/extract_handler.go b/zipserver/extract_handler.go index 03a9d03..05a21a3 100644 --- a/zipserver/extract_handler.go +++ b/zipserver/extract_handler.go @@ -85,6 +85,7 @@ func extractHandler(w http.ResponseWriter, r *http.Request) error { extracted, err := process(ctx) if err != nil { + globalMetrics.TotalErrors.Add(1) return writeJSONError(w, "ExtractError", err) } @@ -112,6 +113,7 @@ func extractHandler(w http.ResponseWriter, r *http.Request) error { errMessage = "Zip extraction timed out" } + globalMetrics.TotalErrors.Add(1) resValues.Add("Type", "ExtractError") resValues.Add("Error", errMessage) log.Print("Extraction failed ", err)