Skip to content

Repository files navigation

oc-statsd Build Status

Greenkeeper badge

OpenComponents plugin for interacting with StatsD inside OC components.

Requirements:

  • Node version: min: 6
  • OC registry
  • StatsD server

Install

npmioc-statsd--save

Registry setup

More info about integrating OC plugins: here

...
constregistry=oc.registry(configuration);registry.register({name: 'statsd',register: require('oc-statsd'),options: {host: 'statsd.hosts.com',prefix: 'oc-registry.prod.vm12345',port: 8125,debug: false}},(err)=>{if(err){console.log('plugin initialisation failed:',err);}else{console.log('statsd now available');}});
...
registry.start(callback);

Using it inside components

Example for a components' server.js:

module.exports.data=(context,callback)=>{constbefore=newDate();conststats=context.plugins.statsd('mycomponent.doSomething');doSomething(()=>{
...
stats.timing('something.happened',newDate()-before);callback(null,{ ... });});};

API

Api for plugin setup:

parametertypemandatorydescription
debugbooleannoDebug mode
hoststringyesThe statsd host
portnumbernoDefault 8152, the statsd port
prefixstringyesThe statsd prefix

Api for plugin usage

The plugin name is declared when initialising a plugin. Following assumes statsd is the designated name.

context.plugins.statsd(namespace)

Gets instance of statsd client in the supplied namespace.

Contributing

Yes please. Open an issue first.

License

MIT

About

OpenComponents statsd plugin

Topics

Resources

Stars

4 stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages