Socket
Socket
Sign inDemoInstall

next-metrics

Package Overview
Dependencies
33
Maintainers
1
Versions
378
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    next-metrics

Drop in metrics for Next Express JS applications, sent to Graphite.


Version published
Weekly downloads
5.8K
decreased by-13.62%
Maintainers
1
Install size
7.39 MB
Created
Weekly downloads
 

Readme

Source

Drop in metrics for Next Express JS applications, sent to Graphite.

Goals

  • Drop in instrumentation for standard parts of the applications - express, ft-api-client etc.
  • Push data to Graphite.
  • Allow for arbitrary metrics to be added.

Usage

Create an instance of the Metrics object,

var Metrics = require('next-metrics');

Initialise it,

Metrics.init({
    app: 'example',
    flushEvery: 5000
});

Instrument the response object,

app.get('/', function (req, res) {
    Metrics.instrument(res, { as: 'express.http.res' });
    res.send('hello')
}

Add a counter for an arbitrary event in the application,

var server = app.listen(port, function () {
    Metrics.count('express.start', 1);
})

See the example app for more information.

Configuration

The library requires your key to hostedgraphite.com to be set in the environment,

export HOSTEDGRAPHITE_APIKEY=...

Do not use the production key on you localhost as you will fill up the Graphite production enviroment account with you local data.

To obtain a key you provision the hostedgraphite addon against a personal app.

The Metrics object takes the following options,

  • app (required) - A string containing the application name, Eg. router, dobi, engels ...
  • flushEvery (required) - A number indicating how frequently you want the metrics pushed to Graphite.

Instrumentation

The libary understands certain types of objects within our set of applications. This saves everyone implementing boilerplate metrics code and avoids different applications inventing their own core measurements.

For example, to instrument an Express response object put this inside one of your route handlers,

Metrics.instrument(res, { as: 'express.http.res' });

The first argument is the object you want instrumenting, and the second argument specifies what type of object it is.

## Metrics

Data is logged in the form of Graphite keys (dots denote hierarchy),

<api-key>.<environment>.<application>.<dyno>.<metric> <value>

Eg,

d3fe0b06-9e43-11e3-b429-00144feab7de.localhost.example._.system.mem_process_heapUsed 16213144
d3fe0b06-9e43-11e3-b429-00144feab7de.localhost.example._.http.res.status_2xx_response_time.mean 758.5
d3fe0b06-9e43-11e3-b429-00144feab7de.localhost.example._.http.res.status_2xx_response_time.stdDev 727.61

Access to graphite is available through the 'ft-next-router-v002' Heroku dashboard.

FAQs

Last updated on 04 Jul 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc