From af54e272d20670063e36446a08e4946cc4829d1c Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Thu, 25 Apr 2024 10:08:23 +0200 Subject: [PATCH] fix: added a check to avoid double counting (#6925) Due to how we handle redirects of embedded proxy, we ended up counting the same request twice. This PR adds a boolean to res.locals which we then check if set to avoid double counting. --- src/lib/middleware/response-time-metrics.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/middleware/response-time-metrics.ts b/src/lib/middleware/response-time-metrics.ts index 648517c3a6..92d5e46614 100644 --- a/src/lib/middleware/response-time-metrics.ts +++ b/src/lib/middleware/response-time-metrics.ts @@ -70,7 +70,9 @@ export function responseTimeMetrics( time, appName, }; - - eventBus.emit(REQUEST_TIME, timingInfo); + if (!res.locals.responseTimeEmitted) { + res.locals.responseTimeEmitted = true; + eventBus.emit(REQUEST_TIME, timingInfo); + } }); }