public static Counter counter(MonitoringInfoMetricName metricName) {
    return new DelegatingCounter(metricName);
  }
@Test
  public void testOperationsUpdateCounterFromContainerWhenContainerIsPresent() {
    HashMap<String, String> labels = new HashMap<String, String>();
    String urn = MonitoringInfoConstants.Urns.ELEMENT_COUNT;
    MonitoringInfoMetricName name = MonitoringInfoMetricName.named(urn, labels);

    MetricsContainer mockContainer = Mockito.mock(MetricsContainer.class);
    Counter mockCounter = Mockito.mock(Counter.class);
    when(mockContainer.getCounter(name)).thenReturn(mockCounter);

    Counter counter = LabeledMetrics.counter(name);

    MetricsEnvironment.setCurrentContainer(mockContainer);
    counter.inc();
    verify(mockCounter).inc(1);

    counter.inc(47L);
    verify(mockCounter).inc(47);

    counter.dec(5L);
    verify(mockCounter).inc(-5);
  }