Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
allow explicit metric name specification (MongoDB plugin only for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
scoates committed Apr 12, 2013
1 parent eaf0f22 commit fddf70b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
14 changes: 9 additions & 5 deletions funnel.js
Expand Up @@ -17,12 +17,16 @@ var collect = function (sourcesdotdotdot) {

var asMetricName = function (data, preserveDot) {
var name = ['funnel'];
name.push(data.funnel);
name.push(fixMetricName(data.nodeName));
if (data.serviceName) {
name.push(fixMetricName(data.serviceName));
if (data.explicitMetricName) {
name.push(data.explicitMetricName);
} else {
name.push(data.funnel);
name.push(fixMetricName(data.nodeName));
if (data.serviceName) {
name.push(fixMetricName(data.serviceName));
}
name.push(fixMetricName(data.metricName, preserveDot));
}
name.push(fixMetricName(data.metricName, preserveDot));
return name.join('.');
};

Expand Down
15 changes: 12 additions & 3 deletions plugin/mongo.js
Expand Up @@ -66,18 +66,27 @@ module.exports = function (service) {
if (typeof service.from == 'string') {
service.from = [service.from];
}

var mongodb = require('mongodb');

service.from.forEach(function (from) {
mongodb.connect(from, function(err, conn) {

for (var serviceName in service.services) {
(function (thisService) {
var funnelerWrapper = function (data) {
if (thisService.metricName) {
data.explicitMetricName = thisService.metricName;
}
funneler(data);
};

if (thisService === shared.COUNT || thisService.count) {
doCount(conn, from, funneler, serviceName, thisService);
doCount(conn, from, funnelerWrapper, serviceName, thisService);
} else if (thisService.query) {
doQuery(conn, from, funneler, serviceName, thisService);
doQuery(conn, from, funnelerWrapper, serviceName, thisService);
} else if (thisService.aggregate) {
doAggregate(conn, from, funneler, serviceName, thisService);
doAggregate(conn, from, funnelerWrapper, serviceName, thisService);
}
})(service.services[serviceName]);
}
Expand Down

0 comments on commit fddf70b

Please sign in to comment.