private void notifyMetricAdded(MetricName name, Metric metric) {
   for (MetricsRegistryListener listener : listeners) {
     listener.onMetricAdded(name, metric);
   }
 }
 /**
  * Adds a {@link MetricsRegistryListener} to a collection of listeners that will be notified on
  * metric creation. Listeners will be notified in the order in which they are added.
  *
  * <p><b>N.B.:</b> The listener will be notified of all existing metrics when it first registers.
  *
  * @param listener the listener that will be notified
  */
 public void addListener(MetricsRegistryListener listener) {
   listeners.add(listener);
   for (Map.Entry<MetricName, Metric> entry : metrics.entrySet()) {
     listener.onMetricAdded(entry.getKey(), entry.getValue());
   }
 }