{"size": 871, "ext": "js", "max_stars_repo_path": "examples/tracer.js", "max_stars_repo_name": "brycebaril/transaction-tracer", "max_stars_repo_stars_event_min_datetime": "2015-09-02T20:10:08.000Z", "max_stars_repo_stars_event_max_datetime": "2015-09-02T20:10:08.000Z", "max_issues_repo_path": "examples/tracer.js", "max_issues_repo_name": "brycebaril/transaction-tracer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "examples/tracer.js", "max_forks_repo_name": "brycebaril/transaction-tracer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.6176470588, "max_line_length": 122, "alphanum_fraction": 0.625717566}
var worker = require("./lib/worker")
var tx = require("../transaction_tracer")

var txlog = {}
tx.onStart(function (event) {
  console.log("[%s] started a transaction (%s)", event.id, event.metadata.type)
  txlog[event.id] = Date.now()
})
tx.onEnd(function (event) {
  var elapsed = Date.now() - txlog[event.id]
  var message = (event.metadata.type == "fetch") ? event.metadata.url + " (status code " + event.metadata.code + ") " : ""
  console.log("[%s] %s %stook %s millis.", event.id, event.metadata.type, message, elapsed)
})

var urls = [
  "http://npmjs.org",
  "http://nodejs.org",
  "http://npm.im",
  "http://brycebaril.com"
]

urls.forEach(function (url) {
  worker(url, tx.start({type: "fetch", url: url}))
})

function simpleTimer() {
  var id = tx.start({type: "timer"})
  setTimeout(function () {
    tx.end(id, {type: "timer"})
  }, 1000)
}

simpleTimer()
