public static Counter getOrCreateCounter(String name) {
    if (self == null) return dummyCounter;
    Map<String, Counter> counters = self.registry.getCounters();
    Counter counter = counters.get(name);
    if (counter != null) return counter;
    // Looks like it doesn't exist.  Lock so that two threads don't create it at once.
    synchronized (Metrics.class) {
      // Recheck to make sure someone didn't create it while we waited.
      counters = self.registry.getCounters();
      counter = counters.get(name);
      if (counter != null) return counter;
      return self.registry.counter(name);
    }
  }
Get an existing counter or create a new one if the requested one does not yet exist.  Creation
is synchronized to assure that only one instance of the counter is created.
@param name name of the counter
@return new Counter, or existing one if it already exists.  This will return null if the
metrics have not been initialized.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/Metrics.java