public static ReadWriteLock wrap(Configuration conf, ReadWriteLock lock,
                                   MetricsSource metrics) {
    Preconditions.checkNotNull(lock, "Caller has to provide valid input lock");
    boolean needsWrap = false;

    if (null != conf) {
      needsWrap =
        HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_COLLECT_LOCK_METRICS);
    }

    if (false == needsWrap) {
      return lock;
    }

    Preconditions.checkNotNull(metrics,
        "Caller has to procide group specific metrics source");
    return new ReadWriteLockMetrics(lock, metrics);
  }
Wraps a <code>ReadWriteLock</code> into a monitored lock if required by
configuration. This helper is checking the <code>
hive.llap.lockmetrics.collect</code> configuration option and wraps the
passed in <code>ReadWriteLock</code> into a monitoring container if the
option is set to <code>true</code>. Otherwise, the original (passed in)
lock instance is returned unmodified.

@param conf Configuration instance to check for LLAP conf options
@param lock The <code>ReadWriteLock</code> to wrap for monitoring
@param metrics The target container for locking metrics
@see #createLockMetricsSource
llap-common/src/java/org/apache/hadoop/hive/llap/metrics/ReadWriteLockMetrics.java