Skip to content

Commit

Permalink
fix: added a check to avoid double counting (#6925)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chriswk committed Apr 25, 2024
1 parent 574eb28 commit af54e27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/middleware/response-time-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}

0 comments on commit af54e27

Please sign in to comment.