org.apache.flink.runtime.metrics.groups.TaskManagerJobMetricGroup Java Examples
The following examples show how to use
org.apache.flink.runtime.metrics.groups.TaskManagerJobMetricGroup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskScopeFormat.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public String[] formatScope( TaskManagerJobMetricGroup parent, AbstractID vertexId, AbstractID attemptId, String taskName, int subtask, int attemptNumber) { final String[] template = copyTemplate(); final String[] values = { parent.parent().hostname(), parent.parent().taskManagerId(), valueOrNull(parent.jobId()), valueOrNull(parent.jobName()), valueOrNull(vertexId), valueOrNull(attemptId), valueOrNull(taskName), String.valueOf(subtask), String.valueOf(attemptNumber) }; return bindVariables(template, values); }
Example #2
Source File: PrometheusReporterTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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"))); }
Example #3
Source File: TaskScopeFormat.java From flink with Apache License 2.0 | 6 votes |
public String[] formatScope( TaskManagerJobMetricGroup parent, AbstractID vertexId, AbstractID attemptId, String taskName, int subtask, int attemptNumber) { final String[] template = copyTemplate(); final String[] values = { parent.parent().hostname(), parent.parent().taskManagerId(), valueOrNull(parent.jobId()), valueOrNull(parent.jobName()), valueOrNull(vertexId), valueOrNull(attemptId), valueOrNull(taskName), String.valueOf(subtask), String.valueOf(attemptNumber) }; return bindVariables(template, values); }
Example #4
Source File: PrometheusReporterTest.java From flink with Apache License 2.0 | 6 votes |
@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"))); }
Example #5
Source File: TaskScopeFormat.java From flink with Apache License 2.0 | 6 votes |
public String[] formatScope( TaskManagerJobMetricGroup parent, AbstractID vertexId, AbstractID attemptId, String taskName, int subtask, int attemptNumber) { final String[] template = copyTemplate(); final String[] values = { parent.parent().hostname(), parent.parent().taskManagerId(), valueOrNull(parent.jobId()), valueOrNull(parent.jobName()), valueOrNull(vertexId), valueOrNull(attemptId), valueOrNull(taskName), String.valueOf(subtask), String.valueOf(attemptNumber) }; return bindVariables(template, values); }
Example #6
Source File: PrometheusReporterTest.java From flink with Apache License 2.0 | 6 votes |
@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<>( createReporterScopedSettings(), new TaskManagerJobMetricGroup(registry, tmMetricGroup, JobID.generate(), "job_1")); reporter.notifyOfAddedMetric(metric1, metricName, metricGroup1); Counter metric2 = new SimpleCounter(); FrontMetricGroup<TaskManagerJobMetricGroup> metricGroup2 = new FrontMetricGroup<>( createReporterScopedSettings(), 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"))); }
Example #7
Source File: PrometheusReporterTaskScopeTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Before public void setupReporter() { registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1", "9400-9500"))); reporter = (PrometheusReporter) registry.getReporters().get(0); 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); }
Example #8
Source File: PrometheusReporterTaskScopeTest.java From flink with Apache License 2.0 | 5 votes |
@Before public void setupReporter() { registry = new MetricRegistryImpl( MetricRegistryConfiguration.defaultMetricRegistryConfiguration(), Collections.singletonList(createReporterSetup("test1", "9400-9500"))); reporter = (PrometheusReporter) registry.getReporters().get(0); 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); }
Example #9
Source File: AbstractStreamOperatorV2.java From flink with Apache License 2.0 | 5 votes |
private LatencyStats createLatencyStats(Configuration taskManagerConfig, int indexInSubtaskGroup) { try { int historySize = taskManagerConfig.getInteger(MetricOptions.LATENCY_HISTORY_SIZE); if (historySize <= 0) { LOG.warn("{} has been set to a value equal or below 0: {}. Using default.", MetricOptions.LATENCY_HISTORY_SIZE, historySize); historySize = MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(); } final String configuredGranularity = taskManagerConfig.getString(MetricOptions.LATENCY_SOURCE_GRANULARITY); LatencyStats.Granularity granularity; try { granularity = LatencyStats.Granularity.valueOf(configuredGranularity.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException iae) { granularity = LatencyStats.Granularity.OPERATOR; LOG.warn( "Configured value {} option for {} is invalid. Defaulting to {}.", configuredGranularity, MetricOptions.LATENCY_SOURCE_GRANULARITY.key(), granularity); } TaskManagerJobMetricGroup jobMetricGroup = this.metrics.parent().parent(); return new LatencyStats(jobMetricGroup.addGroup("latency"), historySize, indexInSubtaskGroup, getOperatorID(), granularity); } catch (Exception e) { LOG.warn("An error occurred while instantiating latency metrics.", e); return new LatencyStats( UnregisteredMetricGroups.createUnregisteredTaskManagerJobMetricGroup().addGroup("latency"), 1, 0, new OperatorID(), LatencyStats.Granularity.SINGLE); } }
Example #10
Source File: PrometheusReporterTaskScopeTest.java From flink with Apache License 2.0 | 5 votes |
@Before public void setupReporter() { registry = new MetricRegistryImpl( MetricRegistryConfiguration.defaultMetricRegistryConfiguration(), Collections.singletonList(createReporterSetup("test1", "9400-9500"))); reporter = (PrometheusReporter) registry.getReporters().get(0); 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); }
Example #11
Source File: ScheduledDropwizardReporterTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "test\"Ta\"..sk"; String jobName = "testJ\"ob:-!ax..?"; String hostname = "loc<>al\"::host\".:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString( ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, "org.apache.flink.dropwizard.ScheduledDropwizardReporterTest$TestingScheduledDropwizardReporter"); configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryConfiguration metricRegistryConfiguration = MetricRegistryConfiguration.fromConfiguration(configuration); MetricRegistryImpl metricRegistry = new MetricRegistryImpl(metricRegistryConfiguration); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); com.codahale.metrics.Meter dropwizardMeter = new com.codahale.metrics.Meter(); DropwizardMeterWrapper meterWrapper = new DropwizardMeterWrapper(dropwizardMeter); taskMetricGroup.counter(counterName, myCounter); taskMetricGroup.meter("meter", meterWrapper); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type ScheduledDropwizardReporter", metricReporter instanceof ScheduledDropwizardReporter); TestingScheduledDropwizardReporter reporter = (TestingScheduledDropwizardReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); Map<Meter, String> meters = reporter.getMeters(); assertTrue(meters.containsKey(meterWrapper)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }
Example #12
Source File: StatsDReporterTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "testTask"; String jobName = "testJob:-!ax..?"; String hostname = "local::host:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString( ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, "org.apache.flink.metrics.statsd.StatsDReporterTest$TestingStatsDReporter"); configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryImpl metricRegistry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(configuration)); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); taskMetricGroup.counter(counterName, myCounter); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type StatsDReporter", metricReporter instanceof StatsDReporter); TestingStatsDReporter reporter = (TestingStatsDReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }
Example #13
Source File: ScheduledDropwizardReporterTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "test\"Ta\"..sk"; String jobName = "testJ\"ob:-!ax..?"; String hostname = "loc<>al\"::host\".:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryConfiguration metricRegistryConfiguration = MetricRegistryConfiguration.fromConfiguration(configuration); MetricRegistryImpl metricRegistry = new MetricRegistryImpl( metricRegistryConfiguration, Collections.singletonList(ReporterSetup.forReporter("test", new TestingScheduledDropwizardReporter()))); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); com.codahale.metrics.Meter dropwizardMeter = new com.codahale.metrics.Meter(); DropwizardMeterWrapper meterWrapper = new DropwizardMeterWrapper(dropwizardMeter); taskMetricGroup.counter(counterName, myCounter); taskMetricGroup.meter("meter", meterWrapper); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type ScheduledDropwizardReporter", metricReporter instanceof ScheduledDropwizardReporter); TestingScheduledDropwizardReporter reporter = (TestingScheduledDropwizardReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); Map<Meter, String> meters = reporter.getMeters(); assertTrue(meters.containsKey(meterWrapper)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }
Example #14
Source File: StatsDReporterTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "testTask"; String jobName = "testJob:-!ax..?"; String hostname = "local::host:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryImpl metricRegistry = new MetricRegistryImpl( MetricRegistryConfiguration.fromConfiguration(configuration), Collections.singletonList(ReporterSetup.forReporter("test", new TestingStatsDReporter()))); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); taskMetricGroup.counter(counterName, myCounter); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type StatsDReporter", metricReporter instanceof StatsDReporter); TestingStatsDReporter reporter = (TestingStatsDReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }
Example #15
Source File: ScheduledDropwizardReporterTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "test\"Ta\"..sk"; String jobName = "testJ\"ob:-!ax..?"; String hostname = "loc<>al\"::host\".:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryConfiguration metricRegistryConfiguration = MetricRegistryConfiguration.fromConfiguration(configuration); MetricRegistryImpl metricRegistry = new MetricRegistryImpl( metricRegistryConfiguration, Collections.singletonList(ReporterSetup.forReporter("test", new TestingScheduledDropwizardReporter()))); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); com.codahale.metrics.Meter dropwizardMeter = new com.codahale.metrics.Meter(); DropwizardMeterWrapper meterWrapper = new DropwizardMeterWrapper(dropwizardMeter); taskMetricGroup.counter(counterName, myCounter); taskMetricGroup.meter("meter", meterWrapper); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type ScheduledDropwizardReporter", metricReporter instanceof ScheduledDropwizardReporter); TestingScheduledDropwizardReporter reporter = (TestingScheduledDropwizardReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); Map<Meter, String> meters = reporter.getMeters(); assertTrue(meters.containsKey(meterWrapper)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }
Example #16
Source File: StatsDReporterTest.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the registered metrics' names don't contain invalid characters. */ @Test public void testAddingMetrics() throws Exception { Configuration configuration = new Configuration(); String taskName = "testTask"; String jobName = "testJob:-!ax..?"; String hostname = "local::host:"; String taskManagerId = "tas:kMana::ger"; String counterName = "testCounter"; configuration.setString(MetricOptions.SCOPE_NAMING_TASK, "<host>.<tm_id>.<job_name>"); configuration.setString(MetricOptions.SCOPE_DELIMITER, "_"); MetricRegistryImpl metricRegistry = new MetricRegistryImpl( MetricRegistryConfiguration.fromConfiguration(configuration), Collections.singletonList(ReporterSetup.forReporter("test", new TestingStatsDReporter()))); char delimiter = metricRegistry.getDelimiter(); TaskManagerMetricGroup tmMetricGroup = new TaskManagerMetricGroup(metricRegistry, hostname, taskManagerId); TaskManagerJobMetricGroup tmJobMetricGroup = new TaskManagerJobMetricGroup(metricRegistry, tmMetricGroup, new JobID(), jobName); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(metricRegistry, tmJobMetricGroup, new JobVertexID(), new AbstractID(), taskName, 0, 0); SimpleCounter myCounter = new SimpleCounter(); taskMetricGroup.counter(counterName, myCounter); List<MetricReporter> reporters = metricRegistry.getReporters(); assertTrue(reporters.size() == 1); MetricReporter metricReporter = reporters.get(0); assertTrue("Reporter should be of type StatsDReporter", metricReporter instanceof StatsDReporter); TestingStatsDReporter reporter = (TestingStatsDReporter) metricReporter; Map<Counter, String> counters = reporter.getCounters(); assertTrue(counters.containsKey(myCounter)); String expectedCounterName = reporter.filterCharacters(hostname) + delimiter + reporter.filterCharacters(taskManagerId) + delimiter + reporter.filterCharacters(jobName) + delimiter + reporter.filterCharacters(counterName); assertEquals(expectedCounterName, counters.get(myCounter)); metricRegistry.shutdown().get(); }