https://github.com/drish/node-accountant
A dead simple to use metrics tracker for node.js http services, it optionally sends data to statsD.
https://github.com/drish/node-accountant
Last synced: 12 months ago
JSON representation
A dead simple to use metrics tracker for node.js http services, it optionally sends data to statsD.
- Host: GitHub
- URL: https://github.com/drish/node-accountant
- Owner: drish
- License: mit
- Created: 2017-01-14T01:46:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-23T20:29:56.000Z (over 9 years ago)
- Last Synced: 2025-06-21T14:19:28.739Z (about 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# node-accountant
[](https://travis-ci.org/drish/node-accountant)
A dead simple to use metrics tracker for node.js http services, it optionally sends data to statsD, or simply prints on stdout.
```
npm install node-accountant
```
The goal of this project is to be a simple to use reponse time metrics tracker for http services.
Instead of polluting your application code with metric code, you can use this lib as a
high level middleware if it fits your needs.
## Examples
### stdout
``` js
const ac = require('node-accountant');
app.use(ac({ delimiter: '.' })); // GET.foo.bar - 4.153 ms
app.get('/foo/bar', handler);
```
### statsd
``` js
const ac = require('node-accountant');
const statsdInfo = {
host: 'localhost',
port: '9988'
}
// will send statsd info in the following format GET.foo.bar
// statsd.timing('GET.foo.bar', responseTime)
app.use(ac({ statsd: statsdInfo }));
app.get('/foo/bar', handler);
app.post('/fii/bor', handler);
```
### simple middleware callback
``` js
const ac = require('node-accountant');
// will send statsd info in the following format GET.endpoint.action
app.use(ac((req, res, metric) => {
console.log(metric.responseTime)
console.log(metric.stat) // data.stat GET.foo.bar
}));
app.get('/foo/bar', handler);
app.post('/fii/bor', handler);
```
## License
[MIT](https://github.com/drish/accountant/blob/master/LICENSE)