public T get(K key) {
    T metric = metrics.get(key);
    if (metric == null) {
      metric = factory.createInstance(key);
      metric = MoreObjects.firstNonNull(metrics.putIfAbsent(key, metric), metric);
    }
    return metric;
  }
@Test
  public void testCreateSeparateInstances() {
    AtomicLong foo = metricsMap.get("foo");
    AtomicLong bar = metricsMap.get("bar");

    assertThat(foo, not(sameInstance(bar)));
  }