private void registerAll(String prefix, MetricSet metricSet, MetricRegistry registry) {
    for (Map.Entry<String, Metric> entry : metricSet.getMetrics().entrySet()) {
      if (entry.getValue() instanceof MetricSet) {
        registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue(), registry);
      } else {
        registry.register(prefix + "." + entry.getKey(), entry.getValue());
      }
    }
  }
@{link JvmMetricsSource} collects JVM Metrics using codahale and publish to Metrics Sink.
ambari-server/src/main/java/org/apache/ambari/server/metrics/system/impl/JvmMetricsSource.java