Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Leverage nodetime to get data into statsd
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
README.md
index.js
package.json

README.md

Wha?

Leverage the excellent nodetime library to take samples, and send it off to statsd!

How?

// make sure this is first!
var StatsdTime = require("statsd-time")
var statsdTime = new StatsdTime("myhost:8025")
statsdTime.profile()

Is it magic?

Nope! Nodetime ties into lots of core node components and makes measurements. It exposes hooks that allow us to get these samples We ship em off to statsd!

This is a really simple way to get data such as HTTP average request time, Mongodb query counts, etc...

What about CPU/Heap profiling?

You still need to use nodetime for that, but if you are looking to avoid sending data to an external service, use look (https://github.com/baryshev/look)

API

By defauly, statsd-time will do the following for any sample:

Send the operation type as a counter. Send the response time (where applicable)

statsdTime.measure("HTTP", function(sample, statsd) {
// do what you want
  statsd.increment("mymetric")

})
// make sure you register BEFORE you call profile!
statsdTime.profile()

Initilization Options statsdTime.profile has the following signature:

new StatsdTime(host)
// or
var object = {
  host: "statsdHost", //default: "localhost:8025"
  port: 8025,
  connection: instance, // an open connection to statsD (uses github.com/msiebuhr/node-statsd-client), overrides host
  nodetime_opts: {}, // pased onto nodetime, use stuff like headless: true to turn off external server access
  prefix: "myApp", // default: ""
}
new StatsdTime(object)
// where object is
Something went wrong with that request. Please try again.