docs: function encode (samples, durations, cb) {
    var agent = samples.length > 0 ? samples[0]._agent : null
    var transactions = groupTransactions(samples, durations)
    var traces = [].concat.apply([], samples.map(function (trans) {
      return trans.traces
    }))
    var groups = groupTraces(traces)
    var raw = rawTransactions(samples)
  
    if (agent && agent.captureTraceStackTraces) {
      addStackTracesToTraceGroups(groups, traces, done)
    } else {
      process.nextTick(done)
    }
  
    function done () {
      cb({ // eslint-disable-line standard/no-callback-literal
        transactions: transactions,
        traces: {
          groups: groups,
          raw: raw
        }
      })
    }
  }