Grimm Pusher
Node module for pushing events to Grimm.
Usage
Install with npm:
$ npm install --save @aptoma/grimm-pusher
Include it in your code:
const grimmPusher = require('@aptoma/grimm-pusher');
const options = {
host: 'https://grimm.example.com',
apiKey: 'secret',
throttleMs: 1000,
maxBatchSize: 100
};
const grimmService = grimmPusher.createService(options);
const grimmServiceSingleton = grimmPusher.singleton();
grimmServiceSingleton.configure(options);
grimmService.on('success', console.info);
grimmService.on('error', console.error);
grimmService.add({
name: 'SomeMetric',
time: Date.now(),
fields: {
msec: 12
},
tags: {
service: 'my-service'
}
});
grimmService.process();
Batching
For better performance, it's recommended to batch events. The default is to send each event immediately, but you are strongly encouraged to enable batching.
You can safely send several hundred events in a batch. If event volume is moderate, sending every second is a good baseline.
Logging and events
GrimmPusher
is an EventEmitter
. The following events may fire:
success
: When process()
succeeds, either due to no pending events, or successful delivery of all events
error
: When process()
fails, either due to missing config or bad response from the backend