npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-instrument

v1.3.4

Published

A library to instrument your node application for Graphite reporting

Downloads

58

Readme

node-instrument

Library to instrument your node application for graphite reporting

Installation

npm install node-instrument

Usage

var instrument = require('node-instrument')();

Options

var options = {
	carbonHost : '127.0.0.1',
	carbonPort : 2003,
	type : 'udp4', // [udp4, tcp4]
	prefix : '',
	suffix : '',
	verbose : false,
	interval : 5000,
	callback : null,
	localAddress: '0.0.0.0' // for tcp binding to specific network adapter
};

Manual Reporting

var instrument = require('node-instrument')({prefix: 'localhost'});
instrument.addObject({myMetric: 1});
instrument.send();

Automated Interval Reporting

var instrument = require('node-instrument')({prefix: 'localhost'});
instrument.start();
instrument.addObject({myMetric: 1});

Put/Add

The 'put' and 'add' methods act slightly different.
put and putObject - replaces the value of a metric if it already exists in the queue.
add and addObject - adds to the value of a metric if it already exists in the queue.

Name/Value metrics

instrument.add('server.metric1', 1);

Object/nested metrics

instrument.addObject({myMetric: 1});
// or
instrument.addObject({myMetric: {sub: 1}});
// or 
instrument.addObject({myMetric: {sub: 1}, 
	deep: {
	   down: 1
	   }
	});

Methods

add: function()

Add metric name/values together

instrument.add('server.metric1', 1); // 'server.metric1' == 1
instrument.add('server.metric1', 1); // 'server.metric1' == 2
instrument.add('server.metric1', 1); // 'server.metric1' == 3

addObject: function()

Add metric object/values together

instrument.addObject({myMetric: {sub: 1}}); // 'myMetric.sub' == 1
instrument.addObject({myMetric: {sub: 1}}); // 'myMetric.sub' == 2
instrument.addObject({myMetric: {sub: 1}}); // 'myMetric.sub' == 3

getQueueAsText: function()

Returns a text readout of the current queue

getQueueSize: function()

Returns the number of metrics waiting in queue

getValueByName: function()

Returns the current value of a metric in the queue

instrument.getValueByName('myMetric.sub'); // number

log: function()

Internal logging function

put: function()

Inserts or replaces the value of a metric in queue

putObject: function()

Inserts or replaces each flattened metric in a queue

send: function()

Manually flush the node-instrument queue and send to Graphite

instrument.send(); // Flushes the internal queue to the Graphite instance

sendCallback: function()

Internal function to execute the options.callback

setGraphiteClient: function()

Convenience method for setting the Graphite Client after node-instrument has been initialized

start: function()

Start the interval reporting of node-instrument

stop: function()

Stops the interval reporting of node-instrument