Skip to content

Instantly share code, notes, and snippets.

@timsavery
Created April 18, 2012 03:10
Show Gist options
  • Save timsavery/2410833 to your computer and use it in GitHub Desktop.
Save timsavery/2410833 to your computer and use it in GitHub Desktop.
statter
var amqp = require('amqp');
var connection = amqp.createConnection();
connection.on('ready', function() {
connection.exchange('ServiceCalls', { type: 'fanout' }, function(exchange) {
connection.queue('AllServiceCalls', function(queue) {
queue.bind(exchange, '#');
queue.subscribe(function(message, headers, deliveryInfo) {
var filter = eval("(function(m) { \
if (m.service && m.operation) { \
return increment(m.service, m.operation); \
} \
})");
var stat = filter(message);
if (stat) {
console.log(stat);
}
});
});
});
});
function increment() {
var keyParts=[];
for (var i = 0; i < arguments.length; i++) {
keyParts.push(arguments[i]);
}
return keyParts.join('.') + ':1|c';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment