From e4a3bd7bad088cccbe3e0880f6681e13b11b3d55 Mon Sep 17 00:00:00 2001 From: Techwraith Date: Wed, 7 Mar 2012 01:25:43 -0800 Subject: [PATCH] Fixing up some metrics output. Implemented the new geddy.config.metrics.namespace config option --- lib/app.js | 5 ++--- lib/metric.js | 9 +++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/app.js b/lib/app.js index 79c80a46..19b16f9c 100644 --- a/lib/app.js +++ b/lib/app.js @@ -148,7 +148,6 @@ var App = function () { , _loadMetrics = function (next) { if (geddy.config.metrics) { geddy.metrics = require('./metric'); - geddy.log.notice(geddy.metrics); } next(); } @@ -225,7 +224,7 @@ var App = function () { // Handle the requests // ================== - var allRequestTimer = geddy.config.metrics && new geddy.metrics.Timer('all-requests') + var allRequestTimer = geddy.config.metrics && geddy.metrics.Timer('all-requests') , controllerActionTimers = {}; geddy.server.addListener('request', function (req, resp) { var reqObj @@ -323,7 +322,7 @@ var App = function () { controllerActionTimers[controllerName] = controllerActionTimers[controller] || {} controllerActionTimers[controllerName][actionName] = controllerActionTimers[controllerName][actionName] || - new geddy.metrics.Timer(controllerName + '.' + actionName) + geddy.metrics.Timer(controllerName + '.' + actionName) controllerActionTimers[controllerName][actionName].update(endTime - accessTime); } }); diff --git a/lib/metric.js b/lib/metric.js index bfc4e063..e66f465d 100644 --- a/lib/metric.js +++ b/lib/metric.js @@ -29,6 +29,9 @@ var Metric = function Metrics(messagePasser, eventType, type) { } Metric.prototype.newMetric = function(type, eventType) { + if (geddy.config.metrics.namespace) { + eventType = geddy.config.metrics.namespace + "." + eventType; + } this.messagePasser.sendMessage({ method: 'createMetric' , type: type @@ -36,12 +39,14 @@ Metric.prototype.newMetric = function(type, eventType) { }); } -Metric.prototype.forwardMessage = function(method, args) { +Metric.prototype.forwardMessage = function(method, args) { this.messagePasser.sendMessage({ method: 'updateMetric' , metricMethod: method , metricArgs: args - , eventType: this.eventType + , eventType: (geddy.config.metrics.namespace) ? + geddy.config.metrics.namespace + "." + this.eventType + : this.eventType }); }