A node client for sending statistics to sitemon.
var Sitemon = require('sitemon-js');
var apiLogger = new Sitemon('apitable', '1.2.3.4:5678');
apiLogger.send({ method: 'tagged.user.getInfo' }, { calls: 1, process_time_ms: 20 }); // sends message to sitemon over UDP
var apiLogger = new Sitemon('api', [
'1.2.3.4:5678',
'2.3.4.5:6789',
'3.4.5.6:7890'
]);
apiLogger.send({ method: 'tagged.user.getInfo' }, { calls: 1, process_time_ms: 20 }); // sends to 1.2.3.4:5678
apiLogger.send({ method: 'tagged.profile.update' }, { calls: 1, process_time_ms: 20 }); // sends to 2.3.4.5:6789
apiLogger.send({ method: 'tagged.stuff.do' }, { calls: 1, process_time_ms: 20 }); // sends to 3.4.5.6:7890
apiLogger.send({ method: 'tagged.photo.info' }, { calls: 1, process_time_ms: 20 }); // sends to 1.2.3.4:5678
The following describes the various files in this repo and the directory structure.
Note: Files and directories prefixed by *
are auto-generated and excluded from the
repository via .gitignore
.
.
├── Gruntfile.js # grunt task configuration
├── README.md # this file
├── *docs # autogenerated documentation
│ └── *index.html # each JS file in `./lib` has a corresponding HTML file for documentation
├── lib # all code for this library will be placed here
│ └── index.js # main entry point for your npm package
├── *node_modules # all dependencies will be installed here by npm
├── package.json # description of this package for npm, including dependency lists
└── test # unit test configuration, reports, and specs
├── *coverage.html # code coverage report
├── lib # specs go here, preferably with a 1:1 mapping to code in `./lib`
│ └── index_test.js # example spec for `./lib/index.js`
├── mocha.opts # runtime options for mocha
└── test_runner.js # configures mocha environment (e.g. chai, sinon, etc.)
Grunt is a JavaScript task runner to automate common actions. The Tagged NPM Package Seed supports the following built-in grunt tasks:
test
Runs all unit tests through mocha.
$ grunt test
coverage
Runs all unit tests and generates a code coverage report in ./test/coverage.html
$ grunt coverage
watch
Automatically runs mocha tests each time a file changes in ./lib
or ./test
.
$ grunt watch
docs
Generates documentation for all JS files within ./lib
using docco. Documentation is
written to ./docs
.
$ grunt docs
clean
Deletes all auto-generated files, including ./docs
and ./test/coverage.html
The ultimate TDD environment for node. Place your specs in ./test/lib
, and run grunt test
.
See ./test/lib/index_test.js
for examples.