forked from sivy/node-statsd
-
Notifications
You must be signed in to change notification settings - Fork 34
Added Event Support #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JamesWiresmith
wants to merge
4
commits into
mrbar42:master
Choose a base branch
from
JamesWiresmith:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f5d1c9
Created basic event support and priority support.
JamesWiresmith 8d39b33
Added support for generating events to datadog through dogstatsd.
JamesWiresmith 88c45aa
Updated README.md
JamesWiresmith 0b70dcd
Removed console.log from the socket send.
JamesWiresmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,31 @@ | ||
| { | ||
| "name" : "node-dogstatsd", | ||
| "description" : "node client for extended StatsD server of Datadog", | ||
| "version" : "0.0.6", | ||
| "author" : "Young Han Lee", | ||
| "repository" : { | ||
| "type" : "git", | ||
| "url" : "git://github.com/joybro/node-dogstatsd.git" | ||
| }, | ||
| "bugs" : { | ||
| "url" : "https://github.com/joybro/node-dogstatsd/issues" | ||
| }, | ||
| "directories" : { | ||
| "lib" : "./lib/" | ||
| }, | ||
| "main" : "./lib/statsd", | ||
| "engines" : { "node" : ">=0.1.97" }, | ||
| "licenses" : [ | ||
| { | ||
| "type" : "MIT", | ||
| "url" : "http://github.com/joybro/node-dogstatsd/raw/master/LICENSE" | ||
| } | ||
| ] | ||
| "name": "node-dogstatsd", | ||
| "description": "node client for extended StatsD server of Datadog", | ||
| "version": "0.0.6", | ||
| "author": "Young Han Lee", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git://github.com/joybro/node-dogstatsd.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/joybro/node-dogstatsd/issues" | ||
| }, | ||
| "directories": { | ||
| "lib": "./lib/" | ||
| }, | ||
| "main": "./lib/statsd", | ||
| "engines": { | ||
| "node": ">=0.1.97" | ||
| }, | ||
| "scripts": {"test": "mocha"}, | ||
| "licenses": [ | ||
| { | ||
| "type": "MIT", | ||
| "url": "http://github.com/joybro/node-dogstatsd/raw/master/LICENSE" | ||
| } | ||
| ], | ||
| "devDependencies": { | ||
| "mocha": "^2.2.5", | ||
| "sinon": "^1.14.1" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * Created by James McNally on 27/05/2015. | ||
| */ | ||
|
|
||
| var assert = require('assert'); | ||
| var sinon = require('sinon'); | ||
| var dogstatsd = require('../lib/statsd.js'); | ||
|
|
||
|
|
||
| describe('Dogstatsd Events Functionality', function() { | ||
|
|
||
|
|
||
| describe('Dogstatd Event Calls', function() { | ||
|
|
||
| var client, sendSpy; | ||
|
|
||
| before(function() { | ||
| client = new dogstatsd.StatsD('localhost',8125); | ||
| //replace send with spy to test without udp. | ||
| sendSpy = sinon.spy(); | ||
| client.send_data = sendSpy; | ||
| }); | ||
|
|
||
| afterEach(function() { | ||
| sendSpy.reset(); | ||
| }); | ||
|
|
||
| after(function() { | ||
| client.close(); | ||
| }); | ||
|
|
||
| it('should send the basic string based on core options', function() { | ||
| client.event('TestTitle', 'TestText'); | ||
| var spyBuffer = sendSpy.args[0][0]; | ||
| assert('_e{9,8}:TestTitle|TestText' === spyBuffer.toString()); | ||
| }); | ||
|
|
||
| it('should include a priority if included in the options', function() { | ||
|
|
||
| client.event('TestTitle', 'TestText', {priority: dogstatsd.priority.NORMAL}); | ||
| var spyBuffer = sendSpy.args[0][0]; | ||
| assert(/\|p:normal/.test(spyBuffer)); | ||
| }); | ||
|
|
||
| it('should include an event type if included in the options', function() { | ||
|
|
||
| client.event('TestTitle', 'TestText', {eventType: dogstatsd.eventType.SUCCESS}); | ||
| var spyBuffer = sendSpy.args[0][0]; | ||
| assert(/\|t:success/.test(spyBuffer)); | ||
| }); | ||
|
|
||
| it('should include an aggregation key if included in the options', function() { | ||
|
|
||
| client.event('TestTitle', 'TestText', {aggKey: 'testkey'}); | ||
| var spyBuffer = sendSpy.args[0][0]; | ||
| assert(/\|k:testkey/.test(spyBuffer)); | ||
| }); | ||
|
|
||
| it('should include tags seperated by commas after a |#', function() { | ||
|
|
||
| client.event('TestTitle', 'TestText', {aggKey: 'testkey'},['tag1:test','tag2:test2','tag3']); | ||
| var packet = sendSpy.args[0][0]; | ||
| assert(/\|#tag1:test,tag2:test2,tag3/.test(packet)); | ||
|
|
||
| }); | ||
| }); | ||
|
|
||
| describe('Event Enums', function() { | ||
|
|
||
| it('should translate enumerated types to correct strings for event priorities', function() { | ||
| assert.equal(dogstatsd.priority.NORMAL, 'normal'); | ||
| assert.equal(dogstatsd.priority.LOW, 'low'); | ||
| }); | ||
|
|
||
| it('should translate enumerated types to correct strings for event types', function() { | ||
|
|
||
| assert.equal(dogstatsd.eventType.ERROR,'error'); | ||
| assert.equal(dogstatsd.eventType.WARNING,'warning'); | ||
| assert.equal(dogstatsd.eventType.INFO,'info'); | ||
| assert.equal(dogstatsd.eventType.SUCCESS,'success'); | ||
|
|
||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * Created by James on 28/05/2015. | ||
| */ | ||
|
|
||
| var assert = require('assert'); | ||
| var sinon = require('sinon'); | ||
| var dogstatsd = require('../lib/statsd.js'); | ||
|
|
||
| describe('dogstatsd Metrics Functionality: ', function() { | ||
|
|
||
| describe('Tags Functionality', function() { | ||
|
|
||
| var client, sendSpy; | ||
|
|
||
| before(function() { | ||
| client = new dogstatsd.StatsD('localhost',8125); | ||
| //replace send with spy to test without udp. | ||
| sendSpy = sinon.spy(); | ||
| client.send_data = sendSpy; | ||
| }); | ||
|
|
||
| afterEach(function() { | ||
| sendSpy.reset(); | ||
| }); | ||
|
|
||
| after(function() { | ||
| client.close(); | ||
| }); | ||
|
|
||
| it('should include tags separated by commas after a |#', function() { | ||
|
|
||
| client.increment('node_test.int',1,['tag1:test','tag2:test2','tag3']); | ||
| var packet = sendSpy.args[0][0]; | ||
| assert(/\|#tag1:test,tag2:test2,tag3/.test(packet)); | ||
|
|
||
| }); | ||
|
|
||
| it('should not include the tags section if no tags are specified', function() { | ||
| client.increment('node_test.int',1); | ||
| var packet = sendSpy.args[0][0]; | ||
| console.log(packet.toString()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ups |
||
| assert.equal(packet.toString(),'node_test.int:1|c'); | ||
|
|
||
| }) | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ups