database: include legacy query() in prometheus metrics

This commit is contained in:
Calvin Montgomery 2017-08-14 18:24:53 -07:00
parent 82004aab73
commit c6c3bafca2
1 changed files with 3 additions and 0 deletions

View File

@ -120,6 +120,7 @@ module.exports.query = function (query, sub, callback) {
console.log(query); console.log(query);
} }
const end = queryLatency.startTimer();
db.knex.raw(query, sub) db.knex.raw(query, sub)
.then(res => { .then(res => {
process.nextTick(callback, null, res[0]); process.nextTick(callback, null, res[0]);
@ -127,7 +128,9 @@ module.exports.query = function (query, sub, callback) {
LOGGER.error('Legacy DB query failed. Query: %s, Substitutions: %j, Error: %s', query, sub, error); LOGGER.error('Legacy DB query failed. Query: %s, Substitutions: %j, Error: %s', query, sub, error);
process.nextTick(callback, 'Database failure', null); process.nextTick(callback, 'Database failure', null);
}).finally(() => { }).finally(() => {
end();
Metrics.stopTimer(timer); Metrics.stopTimer(timer);
queryCount.inc(1, new Date());
}); });
}; };