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 testGet() {
    assertThat(metricsMap.tryGet("foo"), nullValue(AtomicLong.class));

    AtomicLong foo = metricsMap.get("foo");
    assertThat(metricsMap.tryGet("foo"), sameInstance(foo));
  }