Permalink
Browse files

Change Error handling Logic

  • Loading branch information...
1 parent 14a83e1 commit 1fd07dda20e5758e79bbfdad455552ea3a68a39d @draco2003 committed Oct 22, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 stats.js
View
13 stats.js
@@ -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);
});
};

0 comments on commit 1fd07dd

Please sign in to comment.