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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ft-metrics

v0.1.3

Published

A node module that includes helper methods/middleware for recording metrics

Readme

#FtMetrics

FtMetrics is a node module/express middleware that allows you to simply integrate some basic metrics that comply with the Origami Metrics spec

##How to use

###Requireing the object

var ftMetrics = require('ft-metrics');

There is also a configure method that you can use to override some default settings.

var ftMetrics = require('ft-metrics');
ftMetrics.configure({
	movingAveragePeriod: 120 , //seconds to keep moving average for, default 1 minute
	maxSampleSize: 4000, //limits the number of events to keep track of during a moving average period - defaults to 10000.
});

###Gathering metrics

#####Counter

Log a value representing a count, e.g. number of running processes, items in a queue, bytes of disk space remaining, seconds since last new content, etc

ftMetrics.count(key, optionalUnits, optionalDescription)

Examples:

ftMetrics.count('something', 'visits', 'blah description');
ftMetrics.count('something');
ftMetrics.count('something');
ftMetrics.count('something_else');

#####Booleans Log a simple true/false value

ftMetrics.setFlag('some-boolean', false);
ftMetrics.setFlag('some-boolean', true);
ftMetrics.setFlag('some-other-boolean', true, 'A description of the boolean');

#####Response time stats The most common use case for gathering moving average statistics is to measure the response times of an endpoint. FtMetrics provides middleware that will automatically keep track of response times for a given route.

server.get('/v1/someRoute', ftMetrics.monitor(), someAction);

You can also group multiple routes to the same key, by specifying a key to use.

server.get('/route/to/action', ftMetrics.monitor('someAction'), someAction);
server.get('/anotherroute/to/action', ftMetrics.monitor('someAction'), someAction);

#####Manually tracking moving averages. You can also manually calculate stats around some other processes that aren't routes e.g. connecting to a backend service.

var process = ftMetrics.createProcess('blah');
process.start();
process.end();

###Displaying Metrics

You can get an object representation of all the gathered metrics with the getJSON method.

var metrics = ftMetrics.getJSON();

There is also an express method that can be used to handle the __metrics endpoint as per the Origami spec.

server.get('/__metrics', ftMetrics.endpoint);