MetricsConfig extends MapConfig { public List<String> getMetricReporterNames() { Optional<String> metricReporterNamesValue = Optional.ofNullable(get(METRICS_REPORTERS)); if (!metricReporterNamesValue.isPresent() || metricReporterNamesValue.get().isEmpty()) { return Collections.emptyList(); } else { return Stream.of(metricReporterNamesValue.get().split(",")).map(String::trim).collect(Collectors.toList()); } } 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 testGetMetricReporterNames() { Config config = new MapConfig( ImmutableMap.of(MetricsConfig.METRICS_REPORTERS, "reporter0.class, reporter1.class, reporter2.class ")); assertEquals(ImmutableList.of("reporter0.class", "reporter1.class", "reporter2.class"), new MetricsConfig(config).getMetricReporterNames()); Config configEmptyValue = new MapConfig(ImmutableMap.of(MetricsConfig.METRICS_REPORTERS, "")); assertEquals(Collections.emptyList(), new MetricsConfig(configEmptyValue).getMetricReporterNames()); assertEquals(Collections.emptyList(), new MetricsConfig(new MapConfig()).getMetricReporterNames()); }