function makeMiddlewareRecorder(_shim, metricName) {
  return function middlewareMetricRecorder(segment, scope, transaction) {
    const duration = segment.getDurationInMillis()
    const exclusive = segment.getExclusiveDurationInMillis(transaction.trace)

    if (scope) {
      transaction.measure(metricName, scope, duration, exclusive)
    }
    transaction.measure(metricName, null, duration, exclusive)
  }
}
Creates a recorder for middleware metrics.

@private
@param {object} _shim instance of shim
@param {string} metricName name of metric
@returns {Function} recorder for middleware