function _makeTransWrapper(shim, func, name, spec) {
  return function transactionWrapper() {
    let context = shim.tracer.getContext()
    // Don't nest transactions, reuse existing ones!
    const existingTransaction = shim.tracer.getTransaction()
    if (!shim.agent.canCollectData() || existingTransaction) {
      shim.logger.trace('Transaction %s exists, not creating new transaction %s for %s', existingTransaction?.id, spec.type, name)
      return func.apply(this, arguments)
    }

    shim.logger.trace('Creating new %s transaction for %s', spec.type, name)
    const transaction = new Transaction(shim.agent)
    transaction.type = spec.type
    context = context.enterTransaction(transaction)
    return shim.applyContext({ func, context, full: false, boundThis: this, args: arguments })
  }
}
Creates a function that binds transactions to the execution of the function.

A transaction will only be created if there is not a currently active one.

@private
@param {Shim} shim
 The shim used for the binding.
@param {Function} func
 The function link with the transaction.
@param {string} name
 The name of the wrapped function.
@param {TransactionSpec} spec
 The spec for the transaction to create.
@returns {Function} A function which wraps `fn` and potentially creates a new
 transaction linked to the function's execution.