Metrics { public Counter declareCounter(String name) { return declareCounter(name, Dimensions.NONE); } @Inject  Metrics(); Counter declareCounter(String name); Counter declareCounter(String name, Dimensions dimensions); Counter declareCounter(String application, String name, Dimensions dimensions, DimensionType type); Gauge declareGauge(String name); Gauge declareGauge(String name, Dimensions dimensions); Gauge declareGauge(String application, String name, Dimensions dimensions, DimensionType type); List<DimensionMetrics> getDefaultMetrics(); List<DimensionMetrics> getMetricsByType(DimensionType type); void deleteMetricByDimension(String name,  Dimensions dimensionsToRemove, DimensionType type); static final String APPLICATION_HOST; static final String APPLICATION_NODE; }
@Test public void testDefaultValue() { metrics.declareCounter("some.name", hostDimension); assertEquals(getMetricsForDimension(hostDimension).get("some.name"), 0L); }
@Test public void testSimpleIncrementMetric() { Counter counter = metrics.declareCounter("a_counter.value", hostDimension); counter.add(5); counter.add(8); Map<String, Number> latestMetrics = getMetricsForDimension(hostDimension); assertEquals("Expected only 1 metric value to be set", 1, latestMetrics.size()); assertEquals(latestMetrics.get("a_counter.value"), 13L); }