Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add gauge support to statsd plugin.

  • Loading branch information...
commit 28013306476f69241d025293f00e7be446c0deb0 1 parent b5e5013
Bertrand Paquet authored
7 lib/outputs/output_statsd.js
@@ -43,6 +43,13 @@ OutputElasticStatsd.prototype.afterLoadConfig = function(callback) {
43 43 }
44 44 this.raw = this.metric_key + ':' + this.metric_value + '|ms';
45 45 }
  46 + else if (this.metric_type == 'gauge') {
  47 + if (!this.metric_value) {
  48 + this.emit('init_error', new Error('You have to specify metric_value with metric_type gauge'));
  49 + return callback(true);
  50 + }
  51 + this.raw = this.metric_key + ':' + this.metric_value + '|g';
  52 + }
46 53 else {
47 54 this.emit('init_error', new Error('Wrong metric_type: ' + this.metric_type));
48 55 return callback(true);
16 test/test_40_integration.js
@@ -271,11 +271,13 @@ vows.describe('Integration :').addBatch({
271 271 'input://file://input2.txt?type=titi',
272 272 'input://file://input3.txt?type=tata',
273 273 'input://file://input4.txt?type=tete',
  274 + 'input://file://input5.txt?type=toto',
274 275 'filter://regex://?regex=^45_(.*)$&fields=my_field',
275 276 'output://statsd://127.0.0.1:17877?metric_type=increment&metric_key=toto.bouh',
276 277 'output://statsd://127.0.0.1:17877?metric_type=decrement&metric_key=toto.#{@message}&only_type=titi',
277 278 'output://statsd://127.0.0.1:17877?metric_type=counter&metric_key=toto.counter&metric_value=#{@message}&only_type=tata',
278 279 'output://statsd://127.0.0.1:17877?metric_type=timer&metric_key=toto.#{my_field}.#{my_field}&metric_value=20&only_type=tete',
  280 + 'output://statsd://127.0.0.1:17877?metric_type=gauge&metric_key=toto.gauge&metric_value=45&only_type=toto',
279 281 ], function(agent) {
280 282 setTimeout(function() {
281 283 fs.appendFileSync('input1.txt', 'line1\n');
@@ -286,9 +288,12 @@ vows.describe('Integration :').addBatch({
286 288 setTimeout(function() {
287 289 fs.appendFileSync('input4.txt', '45_123\n');
288 290 setTimeout(function() {
289   - agent.close(function() {
290   - callback(undefined, received);
291   - });
  291 + fs.appendFileSync('input5.txt', 'line3\n');
  292 + setTimeout(function() {
  293 + agent.close(function() {
  294 + callback(undefined, received);
  295 + });
  296 + }, 200);
292 297 }, 200);
293 298 }, 200);
294 299 }, 200);
@@ -302,6 +307,7 @@ vows.describe('Integration :').addBatch({
302 307 fs.unlinkSync('input2.txt');
303 308 fs.unlinkSync('input3.txt');
304 309 fs.unlinkSync('input4.txt');
  310 + fs.unlinkSync('input5.txt');
305 311 assert.ifError(err);
306 312 assert.deepEqual(data.sort(), [
307 313 'toto.bouh:1|c',
@@ -310,7 +316,9 @@ vows.describe('Integration :').addBatch({
310 316 'toto.counter:10|c',
311 317 'toto.bouh:1|c',
312 318 'toto.123.123:20|ms',
313   - 'toto.bouh:1|c'
  319 + 'toto.bouh:1|c',
  320 + 'toto.bouh:1|c',
  321 + 'toto.gauge:45|g',
314 322 ].sort());
315 323 }
316 324 },

0 comments on commit 2801330

Please sign in to comment.
Something went wrong with that request. Please try again.