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

View file

@ -120,6 +120,7 @@ module.exports.query = function (query, sub, callback) {
console.log(query);
}
const end = queryLatency.startTimer();
db.knex.raw(query, sub)
.then(res => {
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);
process.nextTick(callback, 'Database failure', null);
}).finally(() => {
end();
Metrics.stopTimer(timer);
queryCount.inc(1, new Date());
});
};