Search in sources :

Example 1 with JobManagerJobMetricGroup

use of org.apache.flink.runtime.metrics.groups.JobManagerJobMetricGroup in project flink by apache.

the class PrometheusReporterTest method metricIsRemovedWhenCollectorIsNotUnregisteredYet.

@Test
void metricIsRemovedWhenCollectorIsNotUnregisteredYet() throws UnirestException {
    JobManagerMetricGroup jmMetricGroup = JobManagerMetricGroup.createJobManagerMetricGroup(registry, HOST_NAME);
    String metricName = "metric";
    Counter metric1 = new SimpleCounter();
    FrontMetricGroup<JobManagerJobMetricGroup> metricGroup1 = new FrontMetricGroup<>(createReporterScopedSettings(), jmMetricGroup.addJob(JobID.generate(), "job_1"));
    reporter.notifyOfAddedMetric(metric1, metricName, metricGroup1);
    Counter metric2 = new SimpleCounter();
    FrontMetricGroup<JobManagerJobMetricGroup> metricGroup2 = new FrontMetricGroup<>(createReporterScopedSettings(), jmMetricGroup.addJob(JobID.generate(), "job_2"));
    reporter.notifyOfAddedMetric(metric2, metricName, metricGroup2);
    reporter.notifyOfRemovedMetric(metric1, metricName, metricGroup1);
    String response = pollMetrics(reporter.getPort()).getBody();
    assertThat(response).doesNotContain("job_1");
}
Also used : JobManagerMetricGroup(org.apache.flink.runtime.metrics.groups.JobManagerMetricGroup) SimpleCounter(org.apache.flink.metrics.SimpleCounter) Counter(org.apache.flink.metrics.Counter) FrontMetricGroup(org.apache.flink.runtime.metrics.groups.FrontMetricGroup) SimpleCounter(org.apache.flink.metrics.SimpleCounter) JobManagerJobMetricGroup(org.apache.flink.runtime.metrics.groups.JobManagerJobMetricGroup) Test(org.junit.jupiter.api.Test)

Aggregations

Counter (org.apache.flink.metrics.Counter)1 SimpleCounter (org.apache.flink.metrics.SimpleCounter)1 FrontMetricGroup (org.apache.flink.runtime.metrics.groups.FrontMetricGroup)1 JobManagerJobMetricGroup (org.apache.flink.runtime.metrics.groups.JobManagerJobMetricGroup)1 JobManagerMetricGroup (org.apache.flink.runtime.metrics.groups.JobManagerMetricGroup)1 Test (org.junit.jupiter.api.Test)1