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

statware

v1.1.3

Published

Node.js process/system/custom metrics aggregation suite with middle-ware like abilities.

Downloads

515

Readme

statware

NPM

Node.js status monitoring wares.

var statware = require("statware")

var stats = statware()

// Optionally install pre-defined metric collections
stats.installProcessInfo()
stats.installSystemInfo()

// Register an asynchronous middleware helper
stats.registerHelper(function (status, next) {
  status.foo = (new Date()).toString()
  next()
})

// Set values manually
stats.set("cat", "meow")

// Incrementers
stats.increment("lines")
stats.increment("lines")
stats.increment("lines")

// windowed stats -- keeps the last `windowSize` records and reports on them
var windowed = stats.windowedStat("games", 10)
windowed.push(50)
windowed.push(100)
windowed.push(75)

// rolling stats for the lifetime of the process
var s = stats.addStat("ht")
s.update(40)
s.update(1000)
s.update(352)
s.update(550)

// namespaces

var ns = stats.namespace("ns")
ns.increment("foo")

// now read the stats by providing a callback function
stats.getStats(function (metrics) {
  console.log(metrics)
})

/*
  { cat: 'meow',
  lines: 3,
  ns: { foo: 1 },
  process_info:
   { uptime: 0,
     memory: { rss: 13094912, heapTotal: 6163968, heapUsed: 1938952 },
     active_requests: 0,
     active_handles: 0,
     versions:
      { http_parser: '1.0',
        node: '0.10.28',
        v8: '3.14.5.9',
        ares: '1.9.0-DEV',
        uv: '0.10.27',
        zlib: '1.2.3',
        modules: '11',
        openssl: '1.0.1g' },
     node_env: '',
     pid: 61429,
     title: 'node',
     user: 'bryce' },
  system_info:
   { freemem: 2590896128,
     totalmem: 17179869184,
     arch: 'x64',
     platform: 'darwin',
     uptime: 4015625,
     loadavg: { '1m': 4.21923828125, '5m': 4.244140625, '15m': 4.0029296875 },
     cores: 8,
     cpu_model: 'Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz',
     cpu_speed: 2600 },
  foo: 'Sun Jun 08 2014 20:23:48 GMT-0700 (PDT)',
  games: { n: 3, min: 50, max: 100, mean: 75 },
  ht:
   { n: 4,
     min: 40,
     max: 1000,
     sum: 1942,
     mean: 485.5,
     variance: 121290.75,
     standard_deviation: 348.2682156040083 },
  statware: { checktime: 1402284228839, stats_runtime: 0.001205082 } }
*/

API

Statware([initial])

Create a statware stats instance, with optional initial value object of initial.

statwareInstance.getStats(callback)

Fetch the stats object. The callback should be of form callback(statsObject) where statsObject is a pure Js object with the statware internal stats.

statwareInstance.registerHelper(helper)

Register an asynchronous helper function to be called whenever stats.getStats(cb) is called. The helper must be in the form of helper(statsObject, next) and must call next() one time. The statsObject is the internal stats object from statware and can be mutated to add, remove, or modify values. Returns itself for chaining.

statwareInstance.set(key, value)

Set a key to a value explicitly

statwareInstance.increment(key)

Update an incrementing key

var fixedArray = statwareInstance.windowedStat(key, windowSize)

Create a FixedArray at key that will have n, min, max, mean reported for it at each getStats() call.

var statsIncremental = statwareInstance.addStat(key)

Create a stats-incremental instance that will report getAll() every time getStats() is run.

var namespace = statwareInstance.namespace(name)

Create a top-level namespace inside the statInstance that behaves almost identically to statwareInstance except it cannot define deeper namespaces.

stawareInstance.installProcessInfo()

Register a pre-defined helper that collects a set of process-related information.

statwareInstance.installSystemInfo()

Register a pre-defined helper that collects a set of system-related information.

LICENSE

MIT