Home

Awesome

koa-trace-influxdb

NPM version Build status Test coverage Dependency Status License Downloads Gittip

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

Limitations