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

measured-core

v2.0.0

Published

A Node library for measuring and reporting application-level metrics.

Downloads

1,242,045

Readme

Measured Core

The core measured library that has the Metric interfaces and implementations.

npm

Install

npm install measured-core

What is in this package

Metric Implemenations

The core library has the following metrics classes:

Gauge

Values that can be read instantly via a supplied call back.

SettableGauge

Just like a Gauge but its value is set directly rather than supplied by a callback.

CachedGauge

Like a mix of the regular and settable Gauge it takes a call back that returns a promise that will resolve the cached value and an interval that it should call the callback on to update its cached value.

Counter

Counters are things that increment or decrement.

Timer

Timers are a combination of Meters and Histograms. They measure the rate as well as distribution of scalar events.

Histogram

Keeps a reservoir of statistically relevant values to explore their distribution.

Meter

Things that are measured as events / interval.

Registry

The core library comes with a basic registry class

Collection

that is not aware of dimensions / tags and leaves reporting up to you.

See the measured-reporting module for more advanced and featured registries.

Other

See The measured-core modules for the full list of exports for require('measured-core').

Usage

Step 1: Add measurements to your code. For example, lets track the requests/sec of a http server:

var http  = require('http');
var stats = require('measured').createCollection();

http.createServer(function(req, res) {
  stats.meter('requestsPerSecond').mark();
  res.end('Thanks');
}).listen(3000);

Step 2: Show the collected measurements (more advanced examples follow later):

setInterval(function() {
  console.log(stats.toJSON());
}, 1000);

This will output something like this every second:

{ requestsPerSecond:
   { mean: 1710.2180279856818,
     count: 10511,
     'currentRate': 1941.4893498239829,
     '1MinuteRate': 168.08263156623656,
     '5MinuteRate': 34.74630977619571,
     '15MinuteRate': 11.646507524106095 } }

Step 3: Aggregate the data into your backend of choice. Here are a few time series data aggregators.

  • Graphite
    • A free and open source, self hosted and managed solution for time series data.
  • SignalFx
    • An enterprise SASS offering for time series data.
  • Datadog
    • An enterprise SASS offering for time series data.