You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by mbode <gi...@git.apache.org> on 2017/09/01 05:54:15 UTC

[GitHub] flink pull request #4586: [FLINK-7502] [metrics] Improve PrometheusReporter

Github user mbode commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4586#discussion_r136503621
  
    --- Diff: flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java ---
    @@ -160,6 +151,43 @@ public void invalidCharactersAreReplacedWithUnderscore() {
     		assertThat(PrometheusReporter.replaceInvalidChars("a,=;:?'b,=;:?'c"), equalTo("a___:__b___:__c"));
     	}
     
    +	@Test
    +	public void registeringSameMetricTwiceDoesNotThrowException() {
    +		Counter counter = new SimpleCounter();
    +		counter.inc();
    +		String counterName = "testCounter";
    +		final FrontMetricGroup<TaskManagerMetricGroup> group = new FrontMetricGroup<>(0, new TaskManagerMetricGroup(registry, HOST_NAME, TASK_MANAGER));
    +
    +		reporter.notifyOfAddedMetric(counter, counterName, group);
    +		reporter.notifyOfAddedMetric(counter, counterName, group);
    +	}
    +
    +	@Test
    +	public void cannotStartTwoReportersOnSamePort() {
    +		final MetricRegistry fixedPort1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1", "12345")));
    +		final MetricRegistry fixedPort2 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test2", "12345")));
    +		assertThat(fixedPort1.getReporters(), hasSize(1));
    +		assertThat(fixedPort2.getReporters(), hasSize(0));
    +	}
    +
    +	@Test
    +	public void canStartTwoReportersWhenUsingPortRange() {
    +		final MetricRegistry portRange1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1", "9249-9252")));
    +		final MetricRegistry portRange2 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test2", "9249-9252")));
    +		assertThat(portRange1.getReporters(), hasSize(1));
    +		assertThat(portRange2.getReporters(), hasSize(1));
    +	}
    +
    +	@Test
    +	public void cannotStartThreeReportersWhenPortRangeIsTooSmall() {
    +		final MetricRegistry smallPortRange1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1", "9253-9254")));
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---