Skip to content

Commit

Permalink
database: include legacy query() in prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
calzoneman committed Aug 15, 2017
1 parent 82004aa commit c6c3baf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ 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]);
}).catch(error => {
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());
});
};

Expand Down

0 comments on commit c6c3baf

Please sign in to comment.