Skip to content

Commit

Permalink
increment errors in response to callback/copy failures
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Nov 24, 2023
1 parent 93fe56e commit 081b636
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zipserver/copy_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions zipserver/extract_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 081b636

Please sign in to comment.