Skip to content

Commit

Permalink
Change Error handling Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
draco2003 committed Oct 22, 2012
1 parent 14a83e1 commit 1fd07dd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,18 @@ function flushMetrics() {
});

pm.process_metrics(metrics_hash, flushInterval, time_stamp, function emitFlush(err, metrics) {
// Flush metrics to each backend.
// Flush metrics to each backend only if the metrics processing was sucessful.
// Add processing_errors counter to allow for monitoring
if (err) {
l.log("Errored processing metrics with: " + err, 'debug');
l.log("Exiting due to error processing metrics with: " + err);
// Send metrics to backends for any last minute processing
// and give backends a chance to cleanup before exiting.
backendEvents.emit('error', time_stamp, metrics, err);
// Only needed if other backends override the standard stacktrace/exit functionality
process.exit(1);
} else {
backendEvents.emit('flush', time_stamp, metrics);
}
backendEvents.emit('flush', time_stamp, metrics);
});

};
Expand Down

0 comments on commit 1fd07dd

Please sign in to comment.