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

metromatic

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metromatic

Listen events on an object and report metrics to StatsD

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
3
Weekly downloads
 
Created
Source

metromatic Build status

Report metrics based on events generated by a given event emitter. Supports StatsD, Cloudwatch & custom backends.

Installation

Install using npm

npm install metromatic

Usage

var Metromatic = require('metromatic');

const backends = [
  {
    type: 'statsd',
    host: 'localhost',
    port: 8125
  },
  {
    type: 'cloudwatch'
    region: 'us-west-1',
    groupName: 'MyService'
    dimensions: { environment: NODE_ENV },
    accessKeyId: AWS_CLOUDWATCH_KEY_ID,
    secretAccessKey: AWS_CLOUDWATCH_ACCESS_KEY,
  },
  {
    type: 'custom',
    send: (type, name, data) => {
      // handle metric storage
    },
  }
];

Metromatic.instrument(myEventEmitter, {
  backends: backends,
  metrics: [{
    name: 'request_time',
    type: 'timing', // timing or gauge currently supported
    eventStart: 'request',
    eventStop: 'response'
  }, {
    name: 'gauge_foo',
    type: 'gauge',
    eventGauge: 'hey'
  }]
});

Eventually, timings and gauges metrics will be sent when myEventEmitter emits the request and response events (for timing) or hey event (for gauge).

If you just want to stop listening the object:

Metromatic.restore(myEventEmitter);

To keep track of multiple timings of the same event pass any id string as a parameter when emitting the events to differentiate them.

Running tests

Run the tests using

npm test

Contributing

At the moment supports timing and gauges metric types. You're more than welcome to express some code love in a Pull Request to make it even more awesome.

Also, if you feel like something is quite not right or want to suggest something, leave us an open issue.

Future enhancements

  • Add more metric types

License (MIT)

FAQs

Package last updated on 01 Nov 2018

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