This commit is contained in:
Karol Wypchlo 2020-09-10 14:05:21 +02:00
parent 6e0f387cf1
commit 70fd6b0f8f
1 changed files with 4 additions and 4 deletions

View File

@ -28,9 +28,9 @@ function getStatusCode() {
/** /**
* Get the sample of most recent critical entries and * Get the sample of most recent critical entries and
* calculate the avarage response time of all of them * calculate the average response time of all of them
*/ */
function getAvarageResponseTime() { function getAverageResponseTime() {
// get most recent 10 successfull checks for the calculation // get most recent 10 successfull checks for the calculation
const sample = db const sample = db
.get("critical") .get("critical")
@ -39,7 +39,7 @@ function getAvarageResponseTime() {
.take(10) .take(10)
.value(); .value();
// calculate avarage time of response // calculate average time of response
return Math.round(sum(sample.map(({ checks }) => sumBy(checks, "time"))) / sample.size); return Math.round(sum(sample.map(({ checks }) => sumBy(checks, "time"))) / sample.size);
} }
@ -59,7 +59,7 @@ function getDisabled() {
module.exports = (req, res) => { module.exports = (req, res) => {
const statusCode = getStatusCode(); const statusCode = getStatusCode();
const timeout = statusCode === StatusCodes.OK ? getAvarageResponseTime() : 0; const timeout = statusCode === StatusCodes.OK ? getAverageResponseTime() : 0;
// We want to delay the response for the load balancer to be able to prioritize // We want to delay the response for the load balancer to be able to prioritize
// servers based on the successful response time of this endpoint. Load balancer // servers based on the successful response time of this endpoint. Load balancer