'use strict';

// We don't want to require strong-agent, because anything it requires will
// become untraceable. Still, we need to use its idea of the appName, and access
// lrtime from the addon, so require the agent internals.
var addon = require('strong-agent/lib/addon');
var assert = require('assert');
var configure = require('strong-agent/lib/config').configure;

exports = module.exports = tracer;
exports.start = start;

var TRACER = null;

var lrtime = addon ? addon.lrtime : undefined;
var options = {
  archiveInterval: 20000,
  accountKey: undefined, // Filled in later
  useHttp: false,
  lrtime: lrtime,
};

function tracer() {
  return TRACER;
}

function start() {
  assert(!TRACER);
  // This is delayed to allow process.env to be modified up until start time.
  var config = configure(null, null, {}, process.env);
  options.accountKey = config.appName;
  if (options.accountKey)
    TRACER = require('strong-trace')(options);
  return TRACER;
}

@@ -613,16 +613,63 @@
 lrtime,%0A
+  blacklist: %5B'*node_modules/strong-agent/*'%5D,%0A
 %7D;%0A%0Afunc

add agent probes to the black list