Skip to content

Collect the current status from your application or libraries and expose them via a web interface

License

Notifications You must be signed in to change notification settings

square/status-collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Status Collector

This package allows packages and applications to setup status collectors into a global place. It allows you to setup topographically named collectors that can be filtered by globbing which can then be exposed for consumption to check the status of your application.

Example

> collectors = require('status-collector'),
collectors = require('./index');
> Q = require('q');
> inspect = require('util').inspect;

collectors.register('my.cool.collector', function() { 
  return { success: true, stuff: 'and', things: true };
});

collectors.register('my.ace.collector', function() { 
  return Q().then(function() { return { success: true, woa: 'crazy'}; }); 
});

> collectors
<StatusCollector collectors=[my.ace.collector, my.cool.collector]>

Now to use them.

# run everything
collectors.execute().then(function(results) {
  console.log(inspect(results, {depth: null}));
});

> [ { name: 'my.cool.collector',
success: true,
results: { success: true, stuff: 'and', things: true } },

{ name: 'my.ace.collector', success: true, results: { success: true, woa: 'crazy' } } ]

We can filter the things to run:

collectors.execute('*.cool.*').then(function(results) {
  console.log(inspect(results, {depth: null}));
});

> [ { name: 'my.cool.collector',
success: true,
results: { success: true, stuff: 'and', things: true } }

Express integration

Add the following to your express app

myApp.use(collectors.expressApp("/my-base-path", express()));

Then hit it:

curl -k -vv  "http://localhost:4567/my-base-path-list"
curl -k -vv  "http://localhost:4567/my-base-path"

When you have something to test, lets say "my.thing.yeah"

curl -k -vv  "http://localhost:4567/my-base-path/my"
curl -k -vv  "http://localhost:4567/my-base-path/my/thing"
curl -k -vv  "http://localhost:4567/my-base-path/my/thing/yeah"
curl -k -vv  "http://localhost:4567/my-base-path/my.*"

About

Collect the current status from your application or libraries and expose them via a web interface

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors