/**
   * Increment a metric by name.
   *
   * @param name of the metric
   * @param factory to lazily create the metric if not null
   */
  public void incr(String name, MetricMutableFactory factory) {
    MetricMutable m = metricsMap.get(name);

    if (m != null) {
      if (m instanceof MetricMutableGauge<?>) {
        ((MetricMutableGauge<?>) m).incr();
      } else if (m instanceof MetricMutableCounter<?>) {
        ((MetricMutableCounter<?>) m).incr();
      } else {
        throw new MetricsException("Unsupported incr() for metric " + name);
      }
    } else if (factory != null) {
      metricsMap.put(name, factory.newMetric(name));
      incr(name, null);
    } else {
      throw new MetricsException("Metric " + name + " doesn't exist");
    }
  }
 /**
  * Increment a metric by name.
  *
  * @param name of the metric
  */
 public void incr(String name) {
   incr(name, mf);
 }