[
https://issues.apache.org/jira/browse/FLINK-4563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15663516#comment-15663516
]
ASF GitHub Bot commented on FLINK-4563:
---------------------------------------
Github user zentol commented on a diff in the pull request:
https://github.com/apache/flink/pull/2650#discussion_r86991226
--- Diff:
flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroupTest.java
---
@@ -44,4 +52,132 @@ protected QueryScopeInfo
createQueryServiceMetricInfo(CharacterFilter filter) {
registry.shutdown();
}
+
+ // for test case: one filter for different reporters with different of
scope delimiter
+ protected static CharacterFilter staticCharacterFilter = new
CharacterFilter() {
+ @Override
+ public String filterCharacters(String input) {
+ return input.replace("C", "RR");
+ }
+ };
+
+ @Test
+ public void filteringForMultipleReporters() {
+ TestReporter1.countSuccessChecks = 0;
+ Configuration config = new Configuration();
+ config.setString(ConfigConstants.METRICS_SCOPE_NAMING_TM,
"A.B.C.D");
+ config.setString(ConfigConstants.METRICS_REPORTERS_LIST,
"test1,test2");
+ config.setString(ConfigConstants.METRICS_REPORTER_PREFIX +
"test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX,
TestReporter1.class.getName());
+ config.setString(ConfigConstants.METRICS_REPORTER_PREFIX +
"test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX,
TestReporter2.class.getName());
+ config.setString(ConfigConstants.METRICS_REPORTER_PREFIX +
"test1." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "-");
+ config.setString(ConfigConstants.METRICS_REPORTER_PREFIX +
"test2." + ConfigConstants.METRICS_REPORTER_SCOPE_DELIMITER, "!");
+
+
+ MetricRegistry testRegistry = new
MetricRegistryTest(MetricRegistryConfiguration.fromConfiguration(config));
+ TaskManagerMetricGroup tmGroup = new
TaskManagerMetricGroup(testRegistry, "host", "id");
+ tmGroup.counter(1);
+ testRegistry.shutdown();
+ assert TestReporter1.countSuccessChecks == 4;
+ }
+
+ @Test
+ public void filteringForNullReporters() {
+ MetricRegistryTest.countSuccessChecks = 0;
+ Configuration config = new Configuration();
+ config.setString(ConfigConstants.METRICS_SCOPE_NAMING_TM,
"A.B.C.D");
+ MetricRegistry testRegistry = new
MetricRegistryTest(MetricRegistryConfiguration.fromConfiguration(config));
+ TaskManagerMetricGroup tmGroupForTestRegistry = new
TaskManagerMetricGroup(testRegistry, "host", "id");
+ assert testRegistry.getReporters().size() == 0;
+ tmGroupForTestRegistry.counter(1);
+ testRegistry.shutdown();
+ assert MetricRegistryTest.countSuccessChecks == 1;
--- End diff --
same as above
> [metrics] scope caching not adjusted for multiple reporters
> -----------------------------------------------------------
>
> Key: FLINK-4563
> URL: https://issues.apache.org/jira/browse/FLINK-4563
> Project: Flink
> Issue Type: Bug
> Components: Metrics
> Affects Versions: 1.1.0
> Reporter: Chesnay Schepler
> Assignee: Anton Mushin
>
> Every metric group contains a scope string, representing what entities
> (job/task/etc.) a given metric belongs to, which is calculated on demand.
> Before this string is cached a CharacterFilter is applied to it, which is
> provided by the callee, usually a reporter. This was done since different
> reporters have different requirements in regards to valid characters. The
> filtered string is cached so that we don't have to refilter the string every
> time.
> This all works fine with a single reporter; with multiple however it is
> completely broken as only the first filter is ever applied.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)