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

grunt-metrics

v0.3.2

Published

Grunt metrics collection.

Downloads

3

Readme

grunt-metrics Build Status

A metrics collection and reporting plugin for Grunt.

Installation

npm install --save-dev grunt-metrics

Quick Usage

  1. Install the plugin
  2. Add grunt.loadNpmTasks("grunt-metrics") to your Gruntfile.
  3. Add metrics as your last task: grunt.registerTask("default", [ ..., "metrics" ]);

Configuration

grunt-metrics can be configured by adding a metrics property to your Grunt config.

Collectors

Collectors gather information at Grunt run time. The current collectors and their options are:

  • build: task duration recording

    no options

  • npm: package information

    | option | required | description | |--------|----------|------------------------| | path | false | path to package.json |

  • git: git information

    no options

  • travis: travis-ci environment variables

    no options

A collector has the following signature:

function collectorName (config) { }

| parameter | description | |-----------|------------------------------------| | config | configuration for this collector |

returns an object with the following schema:

{
    series : String,
    data   : Object
}

Configuration for a collector is looked up in metrics config using its name.

Reporters

Reporters do something with the final metrics gathered by all collectors. Reporters need to be enabled individually. The current reporters and their options are:

  • console: write fancy bar chart to console

    | option | default | required | description | |-----------|----------|----------|-----------------------------------------| | enable | false | false | enable this reporter | | verbose | false | false | output everything | | threshold | 0.001 | false | minimum duration to report | | columns | 80 | false | number of columns the output should use |

  • json: write metrics to a json file

    | option | required | description | |---------|----------|--------------------------------| | path | false | path to write the json file to |

  • influx: write metrics to an InfluxDB database

    | option | default | required | description | |-----------|-----------|----------|-----------------------------------------| | enable | false | false | enable this reporter | | username | n/a | true | database user | | password | n/a | true | database user's password | | database | n/a | true | database to write series to | | host | localhost | false | hostname of the database | | port | 8086 | false | port InfluxDB is listening on |

A reporter has the following signature:

function reporterName (config, metrics) { }

| parameter | description | |-----------|------------------------------------| | config | configuration for this reporter | | metrics | metrics to report |

returns a promise that is resolved when reporting is done Configuration for a reporter is looked up in metrics config using its name.

Example Gruntfile

"use strict";

module.exports = function (grunt) {

    grunt.initConfig({
        metrics : {
            collectors : {

            },
            reporters  : {
                console : {
                    verbose : true
                }
            }
        }
    });

    // Load plugins
    grunt.loadNpmTasks("grunt-metrics");

    grunt.registerTask("test", "Do some tests", function () {
        // testing here
    });

    // Register tasks
    grunt.registerTask("default", [ "test", "metrics" ]);

};

Flow

  • When the plugin is loaded, it hooks the grunt.log.header method.
    • time between calls to these methods are recorded
  • When the task is invoked:
    • All collectors are run at the same time, before reporting.
    • Results from collectors are aggregated in a metrics object like so:
      {
          result.series : result.data
      }
    • The aggregate metrics object is passed to all reporters, at the same time.

Contributing

Create a PR.