Skip to content

koajs/trace-influxdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • host
  • port
  • prefix - prefix to add to all the series, defaulting to trace.. 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.

About

InfluxDB tracing for koa-trace

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published