[ https://issues.apache.org/jira/browse/FLINK-10857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16687753#comment-16687753 ]
ASF GitHub Bot commented on FLINK-10857: ---------------------------------------- kl0u commented on a change in pull request #7095: [FLINK-10857][metrics] Cache logical scopes separately for each reporter URL: https://github.com/apache/flink/pull/7095#discussion_r233781547 ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/metrics/groups/AbstractMetricGroup.java ########## @@ -152,14 +153,35 @@ public String getLogicalScope(CharacterFilter filter) { * @return logical scope */ public String getLogicalScope(CharacterFilter filter, char delimiter) { - if (logicalScopeString == null) { + return getLogicalScope(filter, delimiter, -1); + } + + /** + * Returns the logical scope of this group, for example + * {@code "taskmanager.job.task"}. + * + * @param filter character filter which is applied to the scope components + * @param delimiter delimiter to use for concatenating scope components + * @param reporterIndex index of the reporter + * @return logical scope + */ + public String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) { Review comment: This method could become package private and if I did not mess up, it could become something like: ``` String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) { if (logicalScopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length)) { return getChildLogicalScope(filter, delimiter); } if (logicalScopeStrings[reporterIndex] == null) { logicalScopeStrings[reporterIndex] = getChildLogicalScope(filter, delimiter); } return logicalScopeStrings[reporterIndex]; } private String getChildLogicalScope(CharacterFilter filter, char delimiter) { final String groupName = getGroupName(filter); return parent == null ? groupName : parent.getLogicalScope(filter, delimiter) + delimiter + groupName; } ``` I find this more readable and with less `return`s. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Conflict between JMX and Prometheus Metrics reporter > ---------------------------------------------------- > > Key: FLINK-10857 > URL: https://issues.apache.org/jira/browse/FLINK-10857 > Project: Flink > Issue Type: Bug > Components: Metrics > Affects Versions: 1.5.5, 1.6.2, 1.7.0 > Reporter: Truong Duc Kien > Assignee: Chesnay Schepler > Priority: Major > Labels: pull-request-available > > When registering both JMX and Prometheus metrics reporter, the Prometheus > reporter will fail with many exceptions, such as. > > {code:java} > o.a.f.r.m.MetricRegistryImpl Error while registering metric. > java.lang.IllegalArgumentException: Invalid metric name: > flink_jobmanager.Status.JVM.Memory.Mapped_Count > at > org.apache.flink.shaded.io.prometheus.client.Collector.checkMetricName(Collector.java:182) > at > org.apache.flink.shaded.io.prometheus.client.SimpleCollector.<init>(SimpleCollector.java:164) > at > org.apache.flink.shaded.io.prometheus.client.Gauge.<init>(Gauge.java:68) > at > org.apache.flink.shaded.io.prometheus.client.Gauge$Builder.create(Gauge.java:74) > at > org.apache.flink.metrics.prometheus.AbstractPrometheusReporter.createCollector(AbstractPrometheusReporter.java:130) > at > org.apache.flink.metrics.prometheus.AbstractPrometheusReporter.notifyOfAddedMetric(AbstractPrometheusReporter.java:106) > at > org.apache.flink.runtime.metrics.MetricRegistryImpl.register(MetricRegistryImpl.java:329) > at > org.apache.flink.runtime.metrics.groups.AbstractMetricGroup.addMetric(AbstractMetricGroup.java:379) > at > org.apache.flink.runtime.metrics.groups.AbstractMetricGroup.gauge(AbstractMetricGroup.java:323) > at > org.apache.flink.runtime.metrics.util.MetricUtils.instantiateMemoryMetrics(MetricUtils.java:231) > at > org.apache.flink.runtime.metrics.util.MetricUtils.instantiateStatusMetrics(MetricUtils.java:100) > at > org.apache.flink.runtime.metrics.util.MetricUtils.instantiateJobManagerMetricGroup(MetricUtils.java:68) > at > org.apache.flink.runtime.entrypoint.ClusterEntrypoint.startClusterComponents(ClusterEntrypoint.java:342) > at > org.apache.flink.runtime.entrypoint.ClusterEntrypoint.runCluster(ClusterEntrypoint.java:233) > at > org.apache.flink.runtime.entrypoint.ClusterEntrypoint.lambda$startCluster$0(ClusterEntrypoint.java:191) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:422) > at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1869) > at > org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41) > at > org.apache.flink.runtime.entrypoint.ClusterEntrypoint.startCluster(ClusterEntrypoint.java:190) > at > org.apache.flink.yarn.entrypoint.YarnJobClusterEntrypoint.main(YarnJobClusterEntrypoint.java:176) > {code} > > This is a small program to reproduce the problem: > [https://github.com/dikei/flink-metrics-conflict-test] > > I -- This message was sent by Atlassian JIRA (v7.6.3#76005)