Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow explicit metric name specification (MongoDB plugin only for now)

  • Loading branch information...
commit fddf70b5adb5511f42beff57ec76108dcebbd33f 1 parent eaf0f22
@scoates scoates authored
Showing with 21 additions and 8 deletions.
  1. +9 −5 funnel.js
  2. +12 −3 plugin/mongo.js
View
14 funnel.js
@@ -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('.');
};
View
15 plugin/mongo.js
@@ -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]);
}
Please sign in to comment.
Something went wrong with that request. Please try again.