AbstractMetricGroup implements MetricGroup { @Override public Counter counter(int name) { return counter(String.valueOf(name)); } AbstractMetricGroup(MetricRegistry registry, String[] scope, A parent); Map<String, String> getAllVariables(); String getLogicalScope(CharacterFilter filter); String getLogicalScope(CharacterFilter filter, char delimiter); String[] getScopeComponents(); QueryScopeInfo getQueryServiceMetricInfo(CharacterFilter filter); String getMetricIdentifier(String metricName); String getMetricIdentifier(String metricName, CharacterFilter filter); String getMetricIdentifier(String metricName, CharacterFilter filter, int reporterIndex); void close(); final boolean isClosed(); @Override Counter counter(int name); @Override Counter counter(String name); @Override C counter(int name, C counter); @Override C counter(String name, C counter); @Override G gauge(int name, G gauge); @Override G gauge(String name, G gauge); @Override H histogram(int name, H histogram); @Override H histogram(String name, H histogram); @Override M meter(int name, M meter); @Override M meter(String name, M meter); @Override MetricGroup addGroup(int name); @Override MetricGroup addGroup(String name);  }
@Test public void testScopeCachingForMultipleReporters() throws Exception { Configuration config = new Configuration(); config.setString(MetricOptions.SCOPE_NAMING_TM, "A.B.C.D"); config.setString(MetricOptions.REPORTERS_LIST, "test1,test2"); config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName()); config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-"); config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter2.class.getName()); config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "!"); MetricRegistryImpl testRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config)); try { MetricGroup tmGroup = new TaskManagerMetricGroup(testRegistry, "host", "id"); tmGroup.counter("1"); assertEquals("Reporters were not properly instantiated", 2, testRegistry.getReporters().size()); for (MetricReporter reporter : testRegistry.getReporters()) { ScopeCheckingTestReporter typedReporter = (ScopeCheckingTestReporter) reporter; if (typedReporter.failureCause != null) { throw typedReporter.failureCause; } } } finally { testRegistry.shutdown(); } }