function wrappedPromise(executor) {
    if (!(this instanceof wrappedPromise)) {
      return new Promise(executor)
    }

    const context = agent.tracer.getContext()
    const parent = context.segment
    const transaction = context.transaction
    let promise = null
    if (
      !parent ||
      !transaction.isActive() ||
      typeof executor !== 'function' ||
      arguments.length !== 1
    ) {
      // We are expecting one function argument for executor, anything else is
      // non-standard, do not attempt to wrap. Also do not attempt to wrap if we
      // are not in a transaction.
      const cnstrctArgs = agent.tracer.slice(arguments)
      cnstrctArgs.unshift(Promise) // `unshift` === `push_front`
      promise = new (Promise.bind.apply(Promise, cnstrctArgs))()
    } else {
      const segmentName = 'Promise ' + (executor.name || ANONYMOUS)
      const ctx = {
        promise: null,
        self: null,
        args: null
      }
      promise = new Promise(wrapExecutorContext(ctx))
      ctx.promise = promise
      const segment = _createSegment({ name: segmentName, transaction, parent })
      const newContext = context.enterSegment({ segment })
      Contextualizer.link(null, promise, segment, transaction)

      try {
        // Must run after promise is defined so that `__NR_wrapper` can be set.
        agent.tracer.bindFunction(executor, newContext, true).apply(ctx.self, ctx.args)
      } catch (e) {
        ctx.args[1](e)
      }
    }

    // The Promise must be created using the "real" Promise constructor (using
    // normal Promise.apply(this) method does not work). But the prototype
    // chain must include the wrappedPromise.prototype, V8's promise
    // implementation uses promise.constructor to create new Promises for
    // calls to `then`, `chain` and `catch` which allows these Promises to
    // also be instrumented.
    promise.__proto__ = wrappedPromise.prototype // eslint-disable-line no-proto

    return promise
  }
Wraps the promise handler and binds to the
agent async context manager

@param {Function} executor promise handler
@returns {Function} wrapped handler