koa-trace-influxdb
v1.0.0
Published
[![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependency Status][david-image]][david-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][dow
Downloads
2
Readme
koa-trace-influxdb
Tracing for koa-trace using influxdb-udp.
Usage
var app = koa();
require('koa-trace')(app);
var traceInflux = require('koa-trace-influxdb');
app.instrument(traceInflux({
port: 4444,
host: '127.0.0.1'
}));
app.use(function* (next) {
// set an ID for every request.
// optionally, make this a request UUID
this.id = '1234';
// optionally set properties to add to all traces
this.traces = {
user_id: this.session.user_id.toString('hex')
};
// trace something
this.trace('start')
})
This will create a time series called trace.start
.
Thus, it tracks each event as a separate series.
You probably want to track the elapsed time.
app.use(function* (next) {
var start = Date.now();
yield* next;
this.trace('response-time', {
elapsed: Date.now() - start
});
});
You may want to build your own helper for this.
Options
host
port
prefix
- prefix to add to all the series, defaulting totrace.
. If you don't want any prefixes, set it as''
.
Limitations
- The trace arguments must only be a single object, if anything at all.
- UDP is used underneath, so you may lose events. There is no error reporting for logging these.