Permalink
Browse files

bug 734495: Additional server runner and macro processor summary metrics

  • Loading branch information...
1 parent ffe128b commit f6d062769716bd458d1134bc5744c2a5bb3efd52 @lmorchard lmorchard committed Jul 20, 2012
Showing with 18 additions and 1 deletion.
  1. +9 −0 lib/kumascript/server.js
  2. +9 −1 run.js
View
9 lib/kumascript/server.js
@@ -266,8 +266,17 @@ var Server = ks_utils.Class({
// Measure some misc things from the end event
macro_processor.on('end', function (m) {
+ $this.statsd.increment(ks + 'tokens_ct', m.tokens_ct);
$this.statsd.increment(ks + 'macros_ct', m.macros_ct);
$this.statsd.increment(ks + 'templates_ct', m.templates_ct);
+ $this.statsd.increment(ks + 'errors_ct', m.errors_ct);
+ $this.statsd.increment(ks + 'input_chars', m.input_length);
+ $this.statsd.increment(ks + 'output_chars', m.output_length);
+ if (m.cache_control == 'no-cache') {
+ $this.statsd.increment(ks + 'cache_control.nocache');
+ } else if (m.cache_control == 'max-age: 0') {
+ $this.statsd.increment(ks + 'cache_control.max_age_zero');
+ }
});
// Process the macros...
View
10 run.js
@@ -109,7 +109,10 @@ var worker_list = [];
var is_exiting = false;
function runWorker () {
+ statsd.increment('kumascript.workers_started');
+
process.on('uncaughtException', function (err) {
+ statsd.increment('kumascript.worker_exceptions');
log.error('uncaughtException:', err.message);
log.error(err.stack);
process.exit(1);
@@ -122,6 +125,8 @@ function runWorker () {
}
function runMaster () {
+ statsd.increment('kumascript.masters_started');
+
var master_server;
var master_repl_server;
@@ -141,9 +146,10 @@ function runMaster () {
process.on('SIGINT', performExit);
process.on('uncaughtException', function (err) {
+ statsd.increment('kumascript.master_exceptions');
log.error('uncaughtException:', err.message);
log.error(err.stack);
- //performExit();
+ performExit();
});
function fork () {
@@ -196,6 +202,7 @@ function runMaster () {
// Grab the worker off the top of the list.
var worker = worker_list.shift();
+ statsd.increment('kumascript.port_' + worker.port);
// Assign an ID to this request, for tracking through logs & etc.
var request_id = (request_cnt++) + '-' + worker.pid;
@@ -206,6 +213,7 @@ function runMaster () {
res.end = function (data, enc) {
orig_end.call(res, data, enc);
if (++(worker.requests) >= max_requests) {
+ statsd.increment('kumascript.workers_hit_max_requests');
log.info("Worker PID " + worker.pid + " reached max requests");
worker.kill();
}

0 comments on commit f6d0627

Please sign in to comment.