function _doRecord({ context, args, segDesc, shouldCreateSegment, shim, fn, name }) {
  const { segment } = context
  // Now bind any callbacks specified in the segment descriptor.
  _bindAllCallbacks.call(this, shim, fn, name, args, {
    spec: segDesc,
    segment,
    shouldCreateSegment
  })

  // Apply the function, and (if it returned a stream) bind that too.
  // The reason there is no check for `segment` is because it should
  // be guaranteed by the parent and active transaction check
  // at the beginning of this function.
  let ret = _applyRecorderSegment({
    context,
    boundThis: this,
    args,
    segDesc,
    shim,
    fn,
    name
  })
  if (ret) {
    if (segDesc.stream) {
      shim.logger.trace('Binding return value as stream.')
      _bindStream(shim, ret, segment, {
        event: shim.isString(segDesc.stream) ? segDesc.stream : null,
        shouldCreateSegment
      })
    } else if (segDesc.promise && shim.isPromise(ret)) {
      shim.logger.trace('Binding return value as Promise.')
      ret = shim.bindPromise(ret, segment)
    }
  }
  return ret
}
Binds all callbacks, streams and/or returned promises to the active segment of function being wrapped.

@private
@param {object} params to function
@param {Array} params.args The arguments to the wrapped callback
@param {Spec} params.segDesc Segment descriptor spec
@param {boolean} params.shouldCreateSegment Whether the recorder should create a segment
@param {Shim} params.shim instance of shim
@param {Function} params.fn function being wrapped
@param {Context} params.context agent context to run in
@param {string} params.name name of function being wrapped
@returns {shim|promise} Returns a shim or promise with recorder segment and
bound callbacks, if applicable