This library contains a class to send business probe to knock daemon.
- NodeJS +4.6
- Knockdaemon installed
- An account on Knock
npm install knockprobe
A simple counter, storing a current instant value. Last value provided wins. Gauges are used in quantity cases. For example, a gauge could be defined by the amount of basket being processed.
A simple counter, storing cumulative values and graphing them as delta per second. Increment is typically an recurrent event. For example, an increment could be defined by the number of basket validated.
A simple counter, storing execution time and graphing them by execution time interval. For example, a delay could be defined by the time of execution of external request.
Connect to the Knock daemon first.
var Knock = require('knockprobe');
Knock.connect();
You can push a gauge probe one by one without declaring it first.
Knock.gauge('apple', 2);
Knock.gauge('orange', 3);
Knock.commit();
You can push an increment probe.
Knock.increment('action1', 1);
Knock.commit();
Delay to count is a special probe. This probe aggregate all execution time in a dictionnary of range of time.
var timecode = Knock.start_delay('api_facebook_request');
// do something
Knock.stop_delay(timecode);
Knock.commit();
All data are sent calling commit
command.
You also can use the autocommit feature:
Knock.autocommit(2000); // commit will be called each 2000ms
When disconnecting, a disableable commit is processed first.
Knock.disconnect();
// or
Knock.disconnect(false); // do not commit latest data