Distributed tracing library


Distributed tracing library. Traces are really just a specialized form of log calls, therefore this module utilizes Automattic/log-json under the hood.

Traces works by collecting "cycles", which consist of one or more trace calls enabling you to report on the durations of any given subset of a cycle. For example an image upload "cycle" may look something like the following, where each aspect of this request/response cycled may be "traced" for inspection. Because of this association each Cycle must have its own "id", which may be unique identifier, allowing traces cross-process.

var http = require('http');
var cycle = require('trace-json');
var id = 0;
  var trace = cycle('upload', id++);
  // request comes in, start streaming data 
  // upload complete 
  // resize 
  // resize complete 
  // respond 

To enable a cycle you may use the TRACE environment variable. For example to enable all probes simply use TRACE="*", to enable only chat related cycles use TRACE=chat, for several use spaces or commas TRACE="chat request", TRACE=chat,request. You may also use wildcards such as TRACE=chat:*, and negation via TRACE="* -chat" to say "everything except chat".

Initialize a new Tracer with the given id and name.

Trace start of type with optional date.

Trace end of type with optional date.