Socket
Book a DemoInstallSign in
Socket

simple_stats

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple_stats

Simple client-side statsd logging

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

simple_stats

Super simple client-side stats logging with no dependencies.

Install via github or npm:

npm install benoneal/simple_stats
// or
npm install simple_stats

In your client-side code, include this lib and connect to your statsd server:

var stats = require('simple_stats');

stats.connect({ server: 'http://myappdomain.com/', prefix: 'my_app' });

stats.increment('initialised');
// will give a metric in your logs like: "my_app.initialised.count"

Stats are queued, even before you connect, so you can start timers and collect metrics immediately, even before you know what your statsd server endpoint is, and then sent after you connect.

Once connected, all stats are aggregated and sent every 2.5 seconds. If you need to send queued stats immediately (such as before a page transition or in window.onunload), then call the "flush" method:

window.onunload = stats.flush
// or
form.submit(function() { 
  stats.flush();
  // other stuff here 
});

The timer interface mirrors Lynx's (to make it easier to create isomorphic apps):

var requestTimer = stats.createTimer('get_request');
//...
requestTimer.stop();
// will give something like: "my_app.get_request.timer"

Keywords

statsd

FAQs

Package last updated on 02 Jun 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.