@Test public void metricIsRemovedWhenCollectorIsNotUnregisteredYet() throws UnirestException { TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(registry, HOST_NAME, TASK_MANAGER); String metricName = "metric"; Counter metric1 = new SimpleCounter(); FrontMetricGroup<TaskManagerJobMetricGroup> metricGroup1 = new FrontMetricGroup<>(0, new TaskManagerJobMetricGroup(registry, tmMetricGroup, JobID.generate(), "job_1")); reporter.notifyOfAddedMetric(metric1, metricName, metricGroup1); Counter metric2 = new SimpleCounter(); FrontMetricGroup<TaskManagerJobMetricGroup> metricGroup2 = new FrontMetricGroup<>(0, new TaskManagerJobMetricGroup(registry, tmMetricGroup, JobID.generate(), "job_2")); reporter.notifyOfAddedMetric(metric2, metricName, metricGroup2); reporter.notifyOfRemovedMetric(metric1, metricName, metricGroup1); String response = pollMetrics(reporter.getPort()).getBody(); assertThat(response, not(containsString("job_1"))); }
@VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; }
PrometheusReporter extends AbstractPrometheusReporter { @VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; } }
PrometheusReporter extends AbstractPrometheusReporter { @VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; }  }
PrometheusReporter extends AbstractPrometheusReporter { @VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; }  @Override void open(MetricConfig config); @Override void close(); }
PrometheusReporter extends AbstractPrometheusReporter { @VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; }  @Override void open(MetricConfig config); @Override void close();  }