@Before
  public void before() throws Exception {
    Configuration conf = new Configuration();
    conf.set(MetastoreConf.ConfVars.METRICS_CLASS.getHiveName(), CodahaleMetrics.class.getCanonicalName());
    // disable json file writing
    conf.set(MetastoreConf.ConfVars.METRICS_JSON_FILE_INTERVAL.getHiveName(), "60000m");

    MetricsFactory.init(conf);
    metricRegistry = ((CodahaleMetrics) MetricsFactory.getInstance()).getMetricRegistry();
  }
Unit test for the RatioGauge implementation.
standalone-metastore/metastore-common/src/test/java/org/apache/hadoop/hive/common/metrics/metrics2/TestMetricVariableRatioGauge.java