function dynamoMiddleware(shim, config, next, context) {
  const { commandName } = context
  return async function wrappedMiddleware(args) {
    let endpoint = null
    try {
      endpoint = await getEndpoint(config)
    } catch (err) {
      shim.logger.debug(err, 'Failed to get the endpoint.')
    }

    const getSpec = getDynamoSpec.bind({ endpoint, commandName })
    const wrappedNext = shim.recordOperation(next, getSpec)
    return wrappedNext(args)
  }
}
Middleware hook that records the middleware chain
when command is in a list of monitored commands.

@param {Shim} shim
@param {Object} config AWS SDK client configuration
@param {function} next middleware function
@param {Object} context Context for the running command
@returns {function}