public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsRecordBuilder builder) {
    Map<String, Metric> metrics = metricRegistry.getMetrics();

    for (Map.Entry<String, Metric> e : metrics.entrySet()) {
      // Always capitalize the name
      String name = StringUtils.capitalize(e.getKey());
      Metric metric = e.getValue();

      if (metric instanceof Gauge) {
        addGauge(name, (Gauge<?>) metric, builder);
      } else if (metric instanceof Counter) {
        addCounter(name, (Counter) metric, builder);
      } else if (metric instanceof Histogram) {
        addHistogram(name, (Histogram) metric, builder);
      } else if (metric instanceof Meter) {
        addMeter(name, (Meter) metric, builder);
      } else if (metric instanceof Timer) {
        addTimer(name, (Timer) metric, builder);
      } else {
        LOG.info("Ignoring unknown Metric class " + metric.getClass().getName());
      }
    }
  }
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