npm install oc-statsdoc-statsd 
==========

OpenComponents plugin for interacting with StatsD inside OC components.
* Node version: min: 6
* OC registry
* StatsD server
``js`
npm i oc-statsd --save
More info about integrating OC plugins: here
`js
...
const registry = 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);
`
Example for a components' server.js:
`js
module.exports.data = (context, callback) => {
const before = new Date();
const stats = context.plugins.statsd('mycomponent.doSomething');
doSomething(() => {
...
stats.timing('something.happened', new Date() - before);
callback(null, { ... });
});
};
`
#### Api for plugin setup:
|parameter|type|mandatory|description|
|---------|----|---------|-----------|
|debug|boolean|no|Debug mode|string
|host||yes|The statsd host|number
|port||no|Default 8152, the statsd port|string
|prefix||yes|The 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.
Yes please. Open an issue first.
MIT