onTransactionFinished(transaction) {
    if (!transaction) {
      throw new Error('Error collector got a blank transaction.')
    }
    if (transaction.ignore) {
      return
    }

    // collect user errors even if status code is ignored
    let collectedErrors = 0
    let expectedErrors = 0

    // errors from noticeError are currently exempt from
    // ignore and exclude rules
    ;[collectedErrors, expectedErrors] = this._processErrors(
      transaction,
      collectedErrors,
      expectedErrors,
      'user'
    )

    const isErroredTransaction = urltils.isError(this.config, transaction.statusCode)
    const isIgnoredErrorStatusCode = urltils.isIgnoredError(this.config, transaction.statusCode)

    // collect other exceptions only if status code is not ignored
    if (transaction.exceptions.length && !isIgnoredErrorStatusCode) {
      ;[collectedErrors, expectedErrors] = this._processErrors(
        transaction,
        collectedErrors,
        expectedErrors,
        'transactionException'
      )
    } else if (isErroredTransaction) {
      ;[collectedErrors, expectedErrors] = this._processErrors(
        transaction,
        collectedErrors,
        expectedErrors,
        'transaction'
      )
    }

    const unexpectedErrors = collectedErrors - expectedErrors

    // the metric should be incremented only if the error was not expected
    if (unexpectedErrors > 0) {
      this.metrics
        .getOrCreateMetric(NAMES.ERRORS.PREFIX + transaction.getFullName())
        .incrementCallCount(unexpectedErrors)
    }
  }
Every finished transaction goes through this handler, so do as little as
possible.

TODO: Prob shouldn't do any work if errors fully disabled.

@param {Transaction} transaction the completed transaction