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

axm

v0.2.27

Published

keymetrics I/O adapter

Downloads

83

Readme

PMX module for Keymetrics I/O

PMX is a module that allows you to create advanced interactions with Keymetrics I/O.

With it you can:

  • Trigger remote actions / functions
  • Analyze custom metrics / variables (with utilities like Histogram/Counter/Metric/Meters)
  • Report errors (uncaught exceptions and custom errors)
  • Emit events
  • Analyze HTTP latency

Installation

Build Status

Install PMX and add it to your package.json via:

$ npm install pmx --save

Then init the module to monitor HTTP, Errors and diverse metrics.

var pmx = require('pmx').init();

Custom monitoring

Emit Events

Emit events and get historical and statistics:

var pmx = require('pmx');

pmx.emit('user:register', {
  user : 'Alex registered',
  email : '[email protected]'
});

Make function triggerable

var pmx = require('pmx');

pmx.action('db:clean', { comment : 'Description for this action' }, function(reply) {
  clean.db(function() {
    /**
     * reply() must be called at the end of the action
     */
     reply({success : true});
  });
});

Note: in case of exceptions in the function, your app will not be affected

Errors

Enable catch all errors. This module is enabled by default if you called pmx with the init() function.

pmx.catchAll();

Notify a custom error

pmx.notify({ success : false });

pmx.notify('This is an error');

pmx.notify(new Error('This is an error'));

HTTP latency analysis

Monitor routes, latency and codes. REST complient.

pmx.http(); // You must do this BEFORE any require('http')

This module is enabled by default if you called pmx with the init() function.

Measure

Measure critical segments of you code thanks to 4 kind of probes:

  • Simple metrics: Values that can be read instantly
    • Monitor variable value
  • Counter: Things that increment or decrement
    • Downloads being processed, user connected
  • Meter: Things that are measured as events / interval
    • Request per minute for a http server
  • Histogram: Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution
    • Monitor the mean of execution of a query into database

Metric

Values that can be read instantly.

var probe = pmx.probe();

var metric = probe.metric({
  name  : 'Realtime user',
  value : function() {
    return Object.keys(users).length;
  }
});

Counter

Things that increment or decrement.

var probe = pmx.probe();

var counter = probe.counter({
  name : 'Downloads'
});

http.createServer(function(req, res) {
  counter.inc();
  req.on('end', function() {
    counter.dec();
  });
});

Meter

Things that are measured as events / interval.

var probe = pmx.probe();

var meter = probe.meter({
  name    : 'req/min',
  seconds : 60
});

http.createServer(function(req, res) {
  meter.mark();
  res.end({success:true});
});

Options

seconds option is the measurement rate of the meter, default is 1 seconds

Histogram

Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution.

var probe = pmx.probe();

var histogram = probe.histogram({
  name        : 'latency',
  measurement : 'mean'
});

var latency = 0;

setInterval(function() {
  latency = Math.round(Math.random() * 100);
  histogram.update(latency);
}, 100);

Options

measurement option can be:

  • min: The lowest observed value.
  • max: The highest observed value.
  • sum: The sum of all observed values.
  • variance: The variance of all observed values.
  • mean: The average of all observed values.
  • stddev: The stddev of all observed values.
  • count: The number of observed values.
  • median: 50% of all values in the resevoir are at or below this value.
  • p75: See median, 75% percentile.
  • p95: See median, 95% percentile.
  • p99: See median, 99% percentile.
  • p999: See median, 99.9% percentile.

License

MIT