Count requests even when the info is not complete

This commit is contained in:
Daniel García Aubert 2020-06-19 10:18:06 +02:00
parent a68618c336
commit 22086ba914

View File

@ -79,20 +79,22 @@ module.exports = function metricsCollector () {
const { statusCode, headers } = response; const { statusCode, headers } = response;
const { 'carto-user': user } = headers; const { 'carto-user': user } = headers;
if (statusCode === undefined || headers === undefined || user === undefined) {
this.push(chunk);
return callback();
}
requestCounter.inc(); requestCounter.inc();
userRequestCounter.labels(user, `${statusCode}`).inc();
if (statusCode !== undefined && user !== undefined) {
userRequestCounter.labels(user, `${statusCode}`).inc();
}
if (statusCode >= 200 && statusCode < 400) { if (statusCode >= 200 && statusCode < 400) {
requestOkCounter.inc(); requestOkCounter.inc();
userRequestOkCounter.labels(user, `${statusCode}`).inc(); if (user !== undefined) {
} else { userRequestOkCounter.labels(user, `${statusCode}`).inc();
}
} else if (statusCode >= 400) {
requestErrorCounter.inc(); requestErrorCounter.inc();
userRequestErrorCounter.labels(user, `${statusCode}`).inc(); if (user !== undefined) {
userRequestErrorCounter.labels(user, `${statusCode}`).inc();
}
} }
const { response: responseTime } = stats; const { response: responseTime } = stats;