SharedMetricRegistries { public static MetricRegistry getOrCreate(String name) { final MetricRegistry existing = REGISTRIES.get(name); if (existing == null) { final MetricRegistry created = new MetricRegistry(); final MetricRegistry raced = add(name, created); if (raced == null) { return created; } return raced; } return existing; } private  SharedMetricRegistries(); static void clear(); static Set<String> names(); static void remove(String key); static MetricRegistry add(String name, MetricRegistry registry); static MetricRegistry getOrCreate(String name); synchronized static MetricRegistry setDefault(String name); static MetricRegistry setDefault(String name, MetricRegistry metricRegistry); static MetricRegistry getDefault(); static MetricRegistry tryGetDefault();  }
@Test public void memorizesRegistriesByName() { final MetricRegistry one = SharedMetricRegistries.getOrCreate("one"); final MetricRegistry two = SharedMetricRegistries.getOrCreate("one"); assertThat(one) .isSameAs(two); }