Skip to content

Commit

Permalink
Fix runtime stats sending
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw committed Nov 28, 2018
1 parent 28de6d1 commit c35287c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ if (program.daemonize) {
* Handle signals
*/
const cleanExit = () => {
stats.timeEnd('runtime', 'runtime');
process.exit();
stats.timeEnd('runtime', 'runtime', () => {
process.exit();
});
};
process.on('SIGINT', cleanExit);
process.on('SIGTERM', cleanExit);
Expand Down
4 changes: 2 additions & 2 deletions lib/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ Stats.prototype.time = function time(category, action) {
this.timer[category][action] = Date.now();
};

Stats.prototype.timeEnd = function timeEnd(category, action) {
Stats.prototype.timeEnd = function timeEnd(category, action, cb) {
if (!this.tracker) {
return;
}

this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send();
this.tracker.timing(category, action, Date.now() - this.timer[category][action]).send(cb);
};

module.exports = enabled => new Stats(enabled);

0 comments on commit c35287c

Please sign in to comment.