Git Product home page Git Product logo

statman-gauge's Introduction

statman-gauge Build Status on npm Greenkeeper badge

statman-gauge is one of the metrics from the statman library. Loosely based upon codehale metric package, a gauge is an instantaneous measurement metric. This can be use to capture things like the size of a queue, number of messages processed, or some other interesting thing within your system.

WARNING!! if you look at the word gauge long enough, it looks misspelled

Install it!

Option 1: access directly

Install using npm:

npm install statman-gauge

Reference in your app:

var Gauge = require('statman-gauge');
var gauge = Gauge('gauge-name');

Option 2: access from statman

Install using npm:

npm install statman

Reference in your app:

var statman = require('statman');
var gauge = statman.Gauge('gauge-name');

Use it!

Constructor

  • Gauge() => create instance of a gauge
  • Gauge(name) => create instance of a gauge with name
  • Gauge(name, f()) => create instance of a gauge with name, where f is a function that returns the value for the gauge

Increment

  • increment() => increment value by 1
  • increment(value) => increment by value
gauge.increment();  //increment by 1
gauge.increment(10); //increment by 10

Decrement

  • decrement() => decrement value by 1
  • decrement(value) => decrement by value
gauge.decrement();  //decrement by 1
gauge.decrement(10); //decrement by 10

Set

  • set(value) => set value of gauge
gauge.set(5);

Value

  • value() => get the value of the gauge
gauge.value();

Example:

Suppose that we want to create a gauage that measures that size of a queue. The below indicates how to register this.

Method 1 (use gauge directly)

var Gauge = require('statman-gauge');
var gauge = Gauge('queueSize');

function enqueue(message) {
	data.push(message);
	gauge.increment();
}

function dequeue() {
	data.pop(message);
	gauge.decrement();
}

Method 2 (use gauge via statman)

TODO

Method 3 (use custom value function)

var Gauge = require('statman-gauge');
var gauge = Gauge('queueSize', function() {
	return data.size();
});

function enqueue(message) {
	data.push(message);
}

function dequeue() {
	data.pop(message);
}

Build it!

  • Make sure that you have node and npm installed
  • Clone source code to you local machine
  • Setup dependencies: npm install
  • run tests: npm test

statman-gauge's People

Contributors

greenkeeper[bot] avatar jasonray avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

luckz

statman-gauge's Issues

An in-range update of mocha is breaking the build 🚨

The devDependency mocha was updated from 6.0.2 to 6.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

mocha is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v6.1.0

6.1.0 / 2019-04-07

πŸ”’ Security Fixes

  • #3845: Update dependency "js-yaml" to v3.13.0 per npm security advisory (@plroebuck)

πŸŽ‰ Enhancements

  • #3766: Make reporter constructor support optional options parameter (@plroebuck)
  • #3760: Add support for config files with .jsonc extension (@sstephant)

πŸ“  Deprecations

These are soft-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha:

πŸ› Fixes

  • #3829: Use cwd-relative pathname to load config file (@plroebuck)
  • #3745: Fix async calls of this.skip() in "before each" hooks (@juergba)
  • #3669: Enable --allow-uncaught for uncaught exceptions thrown inside hooks (@givanse)

and some regressions:

πŸ“– Documentation

πŸ”© Other

  • #3830: Replace dependency "findup-sync" with "find-up" for faster startup (@cspotcode)
  • #3799: Update devDependencies to fix many npm vulnerabilities (@XhmikosR)
Commits

The new version differs by 28 commits.

  • f4fc95a Release v6.1.0
  • bd29dbd update CHANGELOG for v6.1.0 [ci skip]
  • aaf2b72 Use cwd-relative pathname to load config file (#3829)
  • b079d24 upgrade deps as per npm audit fix; closes #3854
  • e87c689 Deprecate this.skip() for "after all" hooks (#3719)
  • 81cfa90 Copy Suite property "root" when cloning; closes #3847 (#3848)
  • 8aa2fc4 Fix issue 3714, hide pound icon showing on hover header on docs page (#3850)
  • 586bf78 Update JS-YAML to address security issue (#3845)
  • d1024a3 Update doc examples "tests.html" (#3811)
  • 1d570e0 Delete "/docs/example/chai.js"
  • ade8b90 runner.js: "self.test" undefined in Browser (#3835)
  • 0098147 Replace findup-sync with find-up for faster startup (#3830)
  • d5ba121 Remove "package" flag from sample config file because it can only be passes as CLI arg (#3793)
  • a3089ad update package-lock
  • 75430ec Upgrade yargs-parser dependency to avoid loading 2 copies of yargs

There are 28 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.