Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

segmentio/statsy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

statsy

A simple statsd client.

Installation

$ npm install statsy

Example

var Client = require('statsy');
var http = require('http');
var stats = new Client;

setInterval(function(){
  stats.incr('requests');
  var end = stats.timer('request');
  http.get('http://yahoo.com', function(err, res){
    // do stuff
    end();
  });
}, 1000);

API

Client([opts])

Initialize a client with the given options:

  • host [localhost]
  • port [8125]
  • prefix optional prefix ('.' is appended)
  • tcp use TCP instead of UDP

Events from the socket are forwarded, however by default errors are simply ignored. When TCP is used reconnection attempts will be made until the connection is re-established.

.gauge(name, val)

Send gauge value.

.meter(name, val)

Send meter value.

.set(name, val)

Send set value.

.count(name, val)

Send count value.

.incr(name, [val])

Increment by val or 1.

.decr(name, [val])

Decrement by val or 1.

.histogram(name, val)

Send histogram value.

.histogram(name)

Return histogram delta function.

.timer(name, val)

Send timer value.

.timer(name)

Return timer delta function.

License

MIT

About

Simple statsd client for nodejs

Resources

Stars

Watchers

Forks

Packages

No packages published