You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/08/24 20:32:37 UTC

[GitHub] [beam] y1chi commented on a change in pull request #12674: [BEAM-8258] basic metric feature for nexmark

y1chi commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r475871022



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+
+from __future__ import absolute_import
+
+from time import time
+
+import apache_beam as beam
+from apache_beam.metrics import Metrics
+from apache_beam.testing.benchmarks.nexmark.nexmark_util import MonitorSuffix
+
+
+class Monitor(object):

Review comment:
       Add a documentation on the parameters and the monitored metrics.

##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/nexmark_util.py
##########
@@ -192,6 +194,11 @@ def expand(self, pcoll):
         | "Log" >> beam.Map(log_count_info))
 
 
+class MonitorSuffix:

Review comment:
       can we put this into Monitor class

##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/nexmark_util.py
##########
@@ -221,5 +228,34 @@ def unnest_to_json(cand):
 
 
 def millis_to_timestamp(millis):
+  # type: (int) -> Timestamp
   micro_second = millis * 1000
   return Timestamp(micros=micro_second)
+
+
+def get_counter_metric(result, namespace, name):
+  # type: (PipelineResult, str, str) -> int
+  metrics = result.metrics().query(
+      MetricsFilter().with_namespace(namespace).with_name(name))
+  counters = metrics['counters']
+  if len(counters) > 1:
+    raise ValueError(

Review comment:
       ValueError is normally used to say the function argument being passed is invalid, I think we can use RuntimeError instead.




----------------------------------------------------------------
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:
users@infra.apache.org