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

@nearform/stats

v1.0.1

Published

[![Build Status](https://travis-ci.org/nearform/stats.svg?branch=master)](https://travis-ci.org/nearform/stats)

Downloads

14

Readme

stats

Build Status

Collect stats about your node.js process.

Intro to the nearform stats tooling

Created with the purpose to make creating visualisations about your process easy. At nearform, we achieve this using the modules stats stats-to-elasticsearch and create-stats-dashboard. This makes it very easy to collect process stats in elasticsearch and visualise them in a dashboard in kibana, similar to that below:

Once your dashboard is setup with create-stats-dashboard, all you should need to do is require the stats-to-elasticsearch module and point it at the dashboard to get cool (and useful) visualisations!

Installation

npm install --save @nearform/stats

Usage

This module exports a function which instantiates an event emitter which emits a single event, stats. This event emitter has two functions which can be used to start and stop probing for statistics, start() and stop(). Listen to the stats event to get useful process statistics.

Example:

const StatsProducer = require('@nearform/stats')
const statsProducer = new StatsProducer()
statsProducer.start()
statsProducer.on('stats', function (stats) {
  // so something with these stats
})

// some time later...
statsProducer.stop()

API

StatsProducer(opts)

Returns an event emitter which emits a stats event containing useful stats.

  • opts: an object which can contain the following properties to set for generating statistics
    • sampleInterval: a number representing the amount of seconds to take a sample when running. Defaults to 5 seconds.
    • eventLoopSampleInterval: the interval at which the eventLoop should be sampled, defaults to 500.
    • eventLoopLimit: the maximum amount of delay that is tolerated before overLimit is detected as true, defaults to 50.
    • tags: an array of user defined strings to tag your stats with

The StatsProducer event emitter which is returned has the following methods.

statsProducer.start() - starts the stats producer listening and producing stats.

statsProducer.stop() - stops producing stats.

Stat object

The stat object which is emitted has the following properties:

  • tags: the array of user defined strings defined in the constructor to tag your stats with
  • id: A uuid generated at start up for this stats producer
  • timestamp: The time the stats were generated
  • process: an object with the following properties extracted from the global process object. See the official node documentation for more information on these properties.
    • cpuUsage: This is a function on the process object which is invoked to fill in the value.
    • memoryUsage: This is a function on the process object which is invoked to fill in the value.
    • uptime: This is a function on the process object which is invoked to fill in the value.
    • title
    • pid
    • release
    • versions
    • argv
    • execArgv
    • execPath
  • system: an object with the following properties extracted from the os module. See the official node documentation for more information on these properties.
    • cpus: This is a function on the os module which is invoked at initialisation to fill in the value. This is not expected to change.
    • uptime: This is a function on the os module which is invoked to fill in the value.
    • freemem: This is a function on the os module which is invoked to fill in the value.
    • loadavg: This is a function on the os module which is invoked to fill in the value.
    • platform
    • arch
  • eventLoop: this is an object which contains the following properties extracted from benchmarking the eventloop.
    • delay: The delay in milliseconds (and fractions) from the expected eventloop run. It might be negative (in older nodes).
    • limit: The maximum amount of delay that is tolerated before overLimit becomes true.
    • overlimit: true if the delay > limit.
  • gcRuns: an array with objects added after every gc run. see here to see the format of the objects added

Useful links

License

Apache 2.0