From 94492e812c283b913dbe75c06a789f9f76bee4a6 Mon Sep 17 00:00:00 2001 From: DarthSim Date: Wed, 19 Jul 2023 16:31:00 +0300 Subject: [PATCH] Don't report `context cancelled` errors to metrics collectors --- CHANGELOG.md | 2 ++ processing_handler.go | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e1b1dea..543ecdbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Change +- Don't report `The image request is cancelled` errors. ## [3.18.2] - 2023-07-13 ### Fix diff --git a/processing_handler.go b/processing_handler.go index b8aa5ff0..3b479d7b 100644 --- a/processing_handler.go +++ b/processing_handler.go @@ -167,7 +167,7 @@ func respondWithNotModified(reqID string, r *http.Request, rw http.ResponseWrite ) } -func sendErrAndPanic(ctx context.Context, errType string, err error) { +func sendErr(ctx context.Context, errType string, err error) { send := true if ierr, ok := err.(*ierrors.Error); ok { @@ -183,7 +183,10 @@ func sendErrAndPanic(ctx context.Context, errType string, err error) { if send { metrics.SendError(ctx, errType, err) } +} +func sendErrAndPanic(ctx context.Context, errType string, err error) { + sendErr(ctx, errType, err) panic(err) } @@ -329,7 +332,7 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) { errorreport.Report(err, r) } - metrics.SendError(ctx, "download", err) + sendErr(ctx, "download", err) if imagedata.FallbackImage == nil { panic(err)