MetricsConfig extends MapConfig { public Optional<String> getMetricsFactoryClass(String name) { return Optional.ofNullable(get(String.format(METRICS_REPORTER_FACTORY, name))); } MetricsConfig(Config config); Optional<String> getMetricsFactoryClass(String name); Optional<String> getMetricsSnapshotReporterStream(String name); int getMetricsSnapshotReporterInterval(String name); Optional<String> getMetricsSnapshotReporterBlacklist(String name); List<String> getMetricReporterNames(); boolean getMetricsTimerEnabled(); boolean getMetricsTimerDebugEnabled(); static final String METRICS_REPORTERS; static final String METRICS_REPORTER_FACTORY; static final String METRICS_TIMER_ENABLED; static final String METRICS_TIMER_DEBUG_ENABLED; static final String METRICS_SNAPSHOT_REPORTER_STREAM; static final String METRICS_SNAPSHOT_REPORTER_INTERVAL; static final String METRICS_SNAPSHOT_REPORTER_BLACKLIST; static final String METRICS_SNAPSHOT_REPORTER_NAME_FOR_DIAGNOSTICS; }
@Test public void testGetMetricsFactoryClass() { String metricsReporterName = "metricReporterName"; String metricsReporterValue = "metrics.reporter.class"; Config config = new MapConfig( ImmutableMap.of(String.format(MetricsConfig.METRICS_REPORTER_FACTORY, metricsReporterName), metricsReporterValue)); assertEquals(Optional.of(metricsReporterValue), new MetricsConfig(config).getMetricsFactoryClass(metricsReporterName)); assertFalse(metricsReporterValue, new MetricsConfig(new MapConfig()).getMetricsFactoryClass("someName").isPresent()); }