Installations
npm install node-statsd
Score
98.8
Supply Chain
99
Quality
79.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Developer
sivy
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
>=0.1.97
Typescript Support
No
Node Version
NPM Version
1.4.23
Statistics
439 Stars
92 Commits
166 Forks
6 Watching
1 Branches
19 Contributors
Updated on 19 Sept 2024
Bundle Size
2.12 kB
Minified
903.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
25,630,550
Last day
-14.5%
13,353
Compared to previous day
Last week
-6.7%
72,062
Compared to previous week
Last month
6.4%
307,835
Compared to previous month
Last year
-22.6%
3,978,753
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
node-statsd
A node.js client for Etsy's StatsD server.
This client will let you fire stats at your StatsD server from a node.js application.
node-statsd Runs and is tested on Node 0.6+ on all *nix platforms and 0.8+ on all platforms including Windows.
Installation
$ npm install node-statsd
Usage
All initialization parameters are optional.
Parameters (specified as an options hash):
host
: The host to send stats todefault: localhost
port
: The port to send stats todefault: 8125
prefix
: What to prefix each stat name withdefault: ''
suffix
: What to suffix each stat name withdefault: ''
globalize
: Expose this StatsD instance globally?default: false
cacheDns
: Cache the initial dns lookup to hostdefault: false
mock
: Create a mock StatsD instance, sending no stats to the server?default: false
global_tags
: Optional tags that will be added to every metricdefault: []
All StatsD methods have the same API:
name
: Stat namerequired
value
: Stat valuerequired except in increment/decrement where it defaults to 1/-1 respectively
sampleRate
: Sends only a sample of data to StatsDdefault: 1
tags
: The Array of tags to add to metricsdefault: []
callback
: The callback to execute once the metric has been sent
If an array is specified as the name
parameter each item in that array will be sent along with the specified value.
1 var StatsD = require('node-statsd'), 2 client = new StatsD(); 3 4 // Timing: sends a timing command with the specified milliseconds 5 client.timing('response_time', 42); 6 7 // Increment: Increments a stat by a value (default is 1) 8 client.increment('my_counter'); 9 10 // Decrement: Decrements a stat by a value (default is -1) 11 client.decrement('my_counter'); 12 13 // Histogram: send data for histogram stat 14 client.histogram('my_histogram', 42); 15 16 // Gauge: Gauge a stat by a specified amount 17 client.gauge('my_gauge', 123.45); 18 19 // Set: Counts unique occurrences of a stat (alias of unique) 20 client.set('my_unique', 'foobar'); 21 client.unique('my_unique', 'foobarbaz'); 22 23 // Incrementing multiple items 24 client.increment(['these', 'are', 'different', 'stats']); 25 26 // Sampling, this will sample 25% of the time the StatsD Daemon will compensate for sampling 27 client.increment('my_counter', 1, 0.25); 28 29 // Tags, this will add user-defined tags to the data 30 client.histogram('my_histogram', 42, ['foo', 'bar']); 31 32 // Using the callback 33 client.set(['foo', 'bar'], 42, function(error, bytes){ 34 //this only gets called once after all messages have been sent 35 if(error){ 36 console.error('Oh noes! There was an error:', error); 37 } else { 38 console.log('Successfully sent', bytes, 'bytes'); 39 } 40 }); 41 42 // Sampling, tags and callback are optional and could be used in any combination 43 client.histogram('my_histogram', 42, 0.25); // 25% Sample Rate 44 client.histogram('my_histogram', 42, ['tag']); // User-defined tag 45 client.histogram('my_histogram', 42, next); // Callback 46 client.histogram('my_histogram', 42, 0.25, ['tag']); 47 client.histogram('my_histogram', 42, 0.25, next); 48 client.histogram('my_histogram', 42, ['tag'], next); 49 client.histogram('my_histogram', 42, 0.25, ['tag'], next);
Errors
In the event that there is a socket error, node-statsd
will allow this error to bubble up. If you would like to catch the errors, just attach a listener to the socket property on the instance.
1client.socket.on('error', function(error) { 2 return console.error("Error in socket: ", error); 3});
If you want to catch errors in sending a message then use the callback provided.
License
node-statsd is licensed under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 9/24 approved changesets -- score normalized to 3
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More