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

riemann-util

v0.0.3

Published

Provides utilities and abstractions over node.js riemann.io client

Downloads

3

Readme

riemann-util Build Status

Provides utilities and abstractions over node.js riemann.io client

Install

npm install riemann riemann-util

class RiemannMonitor

A small abstraction over riemann client that provides defaults, demands required fields and simplifies event dispatching.

Example


var RiemannMonitor = require('riemann-util').RiemannMonitor;

var monitor = new RiemannMonitor({
	role: 'ninja',
	ttl: 60 * 60, // 1 hour in seconds
});

var client = ... get a reference to riemann client somehow

monitor.bindClient(client);

monitor.send({
	metric: 5,
	description: 'bar and foo',
	service: 'bar'
});

RiemannMonitor.Ctor(config)

contructs a riemann monitor.

config - see below

RimannMonitor.bindClient(client)

Binds a node.js riemann client to this monitor instance. Monitor will discard events if a client is not bound. If a client is not bound while the first event sent to the monitor, a single warning will be printed using console.warn()

client - an instance of a node.js riemann client

RiemannMonitor.send(event)

Sends an event to riemman. Defaults from config will be applied. Event data here will always override the config, except for tags, which will be concatenated to default tags.

event - a javascript object specifing one or more riemann event fields and their values

RiemannMonitor.errorListener(serviceName, tags)

A convenience callback/event listener generator. Will return a function onError(err) {} that sends error events through this client.

All error events will be sent with default tags, argument tags, the service name and an error tag.

Their metric will be 1, their description will be an inspection of the error argument in onError and their ttl will be the default ttl or the error ttl specified in the config.

The error event time is Date.now() in seconds and its state will be set to critical

serviceName - event service

tags - an array of additional tags

RiemannMonitor._generateHostLabel()

Override this to change the host label generation behavior.

configuration options

Where it makes sense, configuration options can be overridden or augmented when sending an event.

	{
		// required, is sent with every event, included in default tags and might a be part of the host label.
		role: 'worker',

		// required, default ttl in SECONDS for each event
		ttl: 10,

		// optional, an array of tags that will be added to EACH event fired from this monitor
		defaultTags: [],

		// optional, completely override host label generation with a fixed host label. The default host label is [role]-[ip address]-[process id]
		hostLabel: 'my-super-server-is-awesome',

		// optional, if an event is missing a service use this. The default service is 'no_service_name'
		service: 'foo-workers',

		// optional, ttl used for error events generated through errorListener, if omitted ttl is used instead.
		errorTTL: 20,
	}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Yaniv Kessler. Licensed under the MIT license.