Github user StephanEwen commented on a diff in the pull request: https://github.com/apache/flink/pull/2418#discussion_r85146695 --- Diff: flink-metrics/flink-metrics-jmx/src/main/java/org/apache/flink/metrics/jmx/JMXReporter.java --- @@ -206,27 +211,24 @@ public void notifyOfRemovedMetric(Metric metric, String metricName, MetricGroup // Utilities // ------------------------------------------------------------------------ - static String generateJmxName(String metricName, String[] scopeComponents) { - final StringBuilder nameBuilder = new StringBuilder(128); - nameBuilder.append(PREFIX); - - for (int x = 0; x < scopeComponents.length; x++) { - // write keyX= - nameBuilder.append(KEY_PREFIX); - nameBuilder.append(x); - nameBuilder.append("="); - - // write scope component - nameBuilder.append(replaceInvalidChars(scopeComponents[x])); - nameBuilder.append(","); + static Hashtable<String, String> generateJmxTable(Map<String, String> variables) { + Hashtable<String, String> ht = new Hashtable<>(variables.size()); + for (Map.Entry<String, String> variable : variables.entrySet()) { + ht.put(replaceInvalidChars(variable.getKey()), replaceInvalidChars(variable.getValue())); } + return ht; + } - // write the name - nameBuilder.append("name=").append(replaceInvalidChars(metricName)); - - return nameBuilder.toString(); + static String generateJmxDomain(String metricName, MetricGroup group) { + CharacterFilter filter = new CharacterFilter() { --- End diff -- I think this can be a single instance reused across all calls to "generateJmxDomain" in the JMX reporter.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---