Gathering detailed insights and metrics for node-statsd
Gathering detailed insights and metrics for node-statsd
Gathering detailed insights and metrics for node-statsd
Gathering detailed insights and metrics for node-statsd
npm install node-statsd
Typescript
Module System
Min. Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
438 Stars
92 Commits
166 Forks
6 Watchers
1 Branches
18 Contributors
Updated on Dec 01, 2024
Latest Version
0.1.1
Package Id
node-statsd@0.1.1
Size
4.45 kB
NPM Version
1.4.23
Published on
Dec 15, 2014
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
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.
$ npm install node-statsd
All initialization parameters are optional.
Parameters (specified as an options hash):
host
: The host to send stats to default: localhost
port
: The port to send stats to default: 8125
prefix
: What to prefix each stat name with default: ''
suffix
: What to suffix each stat name with default: ''
globalize
: Expose this StatsD instance globally? default: false
cacheDns
: Cache the initial dns lookup to host default: 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 metric default: []
All StatsD methods have the same API:
name
: Stat name required
value
: Stat value required except in increment/decrement where it defaults to 1/-1 respectively
sampleRate
: Sends only a sample of data to StatsD default: 1
tags
: The Array of tags to add to metrics default: []
callback
: The callback to execute once the metric has been sentIf 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);
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.
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
Reason
Found 9/24 approved changesets -- score normalized to 3
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
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