Skip to content

Commit

Permalink
Fixing up some metrics output. Implemented the new geddy.config.metri…
Browse files Browse the repository at this point in the history
…cs.namespace config option
  • Loading branch information
Techwraith committed Mar 7, 2012
1 parent 4155740 commit e4a3bd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/app.js
Expand Up @@ -148,7 +148,6 @@ var App = function () {
, _loadMetrics = function (next) {
if (geddy.config.metrics) {
geddy.metrics = require('./metric');
geddy.log.notice(geddy.metrics);
}
next();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});
Expand Down
9 changes: 7 additions & 2 deletions lib/metric.js
Expand Up @@ -29,19 +29,24 @@ 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
, eventType: 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
});
}

Expand Down

0 comments on commit e4a3bd7

Please sign in to comment.