dianfu commented on a change in pull request #11470: [FLINK-16671][python] 
Support for defining scopes and variables on Python metric group
URL: https://github.com/apache/flink/pull/11470#discussion_r397644867
 
 

 ##########
 File path: 
flink-python/src/main/java/org/apache/flink/python/metric/FlinkMetricContainer.java
 ##########
 @@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.python.metric;
+
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.configuration.MetricOptions;
+import org.apache.flink.fnexecution.v1.FlinkFnApi;
+import org.apache.flink.metrics.MetricGroup;
+
+import java.util.Arrays;
+
+/**
+ * Helper class for forwarding metric group information from Java to Python 
and forward Python
+ * metrics to Java accumulators and metrics.
+ */
+public class FlinkMetricContainer {
+
+       private static final String METRIC_KEY_SEPARATOR =
+               
GlobalConfiguration.loadConfiguration().getString(MetricOptions.SCOPE_DELIMITER);
+
+       private final MetricGroup baseMetricGroup;
+
+       public FlinkMetricContainer(MetricGroup metricGroup) {
+               this.baseMetricGroup = metricGroup;
+       }
+
+       public FlinkFnApi.MetricGroupInfo getBaseMetricGroupInfo() {
+               FlinkFnApi.MetricGroupInfo.Builder builder = 
FlinkFnApi.MetricGroupInfo.newBuilder();
+               // components
+               builder.addAllScopeComponents(
+                       Arrays.asList(baseMetricGroup.getScopeComponents()));
 
 Review comment:
   Replace with `Collections.singletonList`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

Reply via email to