private void addGauge(String name, Gauge<?> gauge, MetricsRecordBuilder builder) {
    final MetricsInfo info = Interns.info(name, EMPTY_STRING);
    final Object o = gauge.getValue();

    // Figure out which gauge types metrics2 supports and call the right method
    if (o instanceof Integer) {
      builder.addGauge(info, (int) o);
    } else if (o instanceof Long) {
      builder.addGauge(info, (long) o);
    } else if (o instanceof Float) {
      builder.addGauge(info, (float) o);
    } else if (o instanceof Double) {
      builder.addGauge(info, (double) o);
    } else {
      LOG.warn("Ignoring Gauge (" + name + ") with unhandled type: " + o.getClass());
    }
  }
Iterates over the MetricRegistry and adds them to the {@code builder}.
@param builder A record builder
hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/metrics/impl/HBaseMetrics2HadoopMetricsAdapter.java