Probe npm registries for statistics
MIT License
Probe npm registries for statistics
Instantiate a new npm-probe instance which will collect statistics from npm
registries and mirrors. If you'd like to run the instance without actively
gathering data, provide the flag silent: true
.
var Collector = require('npm-probe');
, collector = new Collector({
npm: nodejitsu.config.get('npm'),
probes: [ Collector.probes.ping ],
silent: false
});
Active execution of the probes can be prevented by setting the following
environment variable: PROBE=silent
. This allows you to use the collector as
static instance to access cache or other methods.
Providing an alternative or reduced list of registries is possible by setting
options.registries
. The list should be an object with unique registry names,
see registries.json
for an example.
The ping probe will perform 5 parallel request to the database page of each registry's CouchDB. The response time of these 5 request are averaged and statistics (min, max, stdev) will be calculated.
This probe works on the back of the SkimDB feed follower. Modules stored in the feed collection will be checked against each listed registry/mirror. The lag is determined from the latest known update time for each module. The difference is calculated in milliseconds. Only modules that are lagging, e.g. have a difference > 0 will be included in the statistics.
This probe is designed to publish to the npmjs.org registry and can be used to check publishing consistency and actual duration. The semantic version is updated as follows:
To contribute, simply clone the repository and submit pull requests. Please provide unit tests with each change.
git clone [email protected]:Moveo/npm-probe.git
If you like to design a custom probe, note that the following methods should be
available on the API of the probe. The parameters will be provided
from the main Collector
instance. In addition to that fusing is available to
create read-only properties on the probe.
To aquire a predefined Probe constructor the factory method Collector.create
can be used. After add all API methods to the provided constructor. Make sure that
the time schedule specifications are compatible with node-schedule.
require('npm-probe').create(
'mycustomprobe', // name of the probe
{ minute: new schedule.Range(0, 60, 1) } // time schedule
);
Actual logic that gets executed whenever the timing schedule triggers a run.
Return transformed data, this can be done via grouping or calculating moving averages or any other map reduce methodology.
Return the value that should be used as latest value.
Group functionality by time, group per millisecond, hour or day.