flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnowojski <...@git.apache.org>
Subject [GitHub] flink pull request #4908: [FLINK-7933][metrics] Improve PrometheusReporter t...
Date Fri, 27 Oct 2017 09:01:42 GMT
Github user pnowojski commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4908#discussion_r147357745
  
    --- Diff: flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTaskScopeTest.java
---
    @@ -72,10 +72,30 @@
     	private final AbstractID taskAttemptId2 = new AbstractID();
     	private final String[] labelValues2 = {jobId.toString(), taskId2.toString(), taskAttemptId2.toString(),
TASK_MANAGER_HOST, TASK_NAME, "" + ATTEMPT_NUMBER, JOB_NAME, TASK_MANAGER_ID, "" + SUBTASK_INDEX_2};
     
    -	private final TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(registry,
TASK_MANAGER_HOST, TASK_MANAGER_ID);
    -	private final TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(registry,
tmMetricGroup, jobId, JOB_NAME);
    -	private final TaskMetricGroup taskMetricGroup1 = new TaskMetricGroup(registry, tmJobMetricGroup,
taskId1, taskAttemptId1, TASK_NAME, SUBTASK_INDEX_1, ATTEMPT_NUMBER);
    -	private final TaskMetricGroup taskMetricGroup2 = new TaskMetricGroup(registry, tmJobMetricGroup,
taskId2, taskAttemptId2, TASK_NAME, SUBTASK_INDEX_2, ATTEMPT_NUMBER);
    +	private TaskMetricGroup taskMetricGroup1;
    +	private TaskMetricGroup taskMetricGroup2;
    +
    +	private MetricRegistry registry;
    +	private int port;
    +
    +	@Before
    +	public void setupReporter() {
    +		registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1",
"9400-9500")));
    +		PrometheusReporter reporter = (PrometheusReporter) registry.getReporters().get(0);
    +		port = reporter.getPort();
    +
    +		TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(registry, TASK_MANAGER_HOST,
TASK_MANAGER_ID);
    +		TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(registry,
tmMetricGroup, jobId, JOB_NAME);
    +		taskMetricGroup1 = new TaskMetricGroup(registry, tmJobMetricGroup, taskId1, taskAttemptId1,
TASK_NAME, SUBTASK_INDEX_1, ATTEMPT_NUMBER);
    +		taskMetricGroup2 = new TaskMetricGroup(registry, tmJobMetricGroup, taskId2, taskAttemptId2,
TASK_NAME, SUBTASK_INDEX_2, ATTEMPT_NUMBER);
    +	}
    +
    +	@After
    +	public void shutdownRegistry() {
    +		if (registry != null) {
    +			registry.shutdown();
    --- End diff --
    
    you are not closing the reporter here. Isn't this a root cause of the test instability?


---

Mime
View raw message