Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monitor-dog

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monitor-dog

A helpful wrapper for dogstatsd.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

monitor-dog

Build Status Dependency Status devDependency Status

NPM

Wraps dogstatsd to provide environment based event scoping (prefixing) and timers.

Usage

// Assume `process.env.MONITOR_PREFIX === 'myProject'`, then all events
// triggered via monitor dog will be prefixed with `myProject.`.
var monitor = require('monitor-dog');

// Trigger an increment (`myProject.requests`)
monitor.increment('requests');

// Trigger a gauge event (`myProject.404s`)
monitor.gauge('404s');

// Time requests...
var timer = monitor.timer('request.time');
request('http://example.com', function(req, res) {
  // Triggers a histogram event to `myProject.request.time`
  timer.stop();
});

Documentation

.set, .increment, .histogram, .gauge

These methods behave exactly as you would expect on a regular dogstatsd Client.

.timer(name, [startNow])

Creates and returns new timer with the given name. Optional boolean startNow can be provided to start the timer at a later date using the .start method.

Synchronous
// Create the timer
var sumTimer = monitor.timer('sum.time');

// Perform a computation
var sum = 0;
for (var i = 0; i < 1000000; i++) {
  sum += i;
}

// Call .stop() to send a histogram event named 'sum.time'
// with the recorded duration...
sumTimer.stop();
Asynchronous
var requestTimer = monitor.timer('request.time');
request('/some/endpoint', function (err, res) {
  requestTimer.stop();
});
Delayed Use
var delayedTime = monitor.timer('delayed.timer', false);

// ... Do some other stuff ...

delayedTimer.start();

// ... Do some more stuff ...

delayedTimer.stop();
Sockets data monitoring

Automatically track number of open & pending sockets and open files.

// start monitoring once you start web server
// default interval defined by `process.env.MONITOR_INTERVAL`
monitor.startSocketsMonitor();

// stop monitoring before stopping web server
monitor.stopSocketsMonitor();

License

MIT

Keywords

FAQs

Package last updated on 10 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc