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 19:27:15 UTC

[GitHub] [beam] leiyiz opened a new pull request #12674: [BEAM-8258] basic metric feature for nexmark

leiyiz opened a new pull request #12674:
URL: https://github.com/apache/beam/pull/12674


   added beam-metric based performance monitoring
   performance are logged to console after the query is done or canceled by nexmark suite
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   Post-Commit Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   
   Lang | SDK | Dataflow | Flink | Samza | Spark | Twister2
   --- | --- | --- | --- | --- | --- | ---
   Go | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/) | --- | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/) | --- | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/) | ---
   Java | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/badge/i
 con)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)<br>[![Build Status](htt
 ps://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming/lastCompletedBuild/) | [![Build Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Twister2/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Twister2/lastCompletedBuild/)
   Python | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python2/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python35/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python36/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python37/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python38/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python38/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_
 Py_VR_Dataflow/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Py_VR_Dataflow_V2/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Py_ValCont/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python2_PVR_Flink_Cron/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python35_VR_Flink/lastCompletedBuild/) | --- | [![Build Status](https://ci-beam.apache.org/job/beam_P
 ostCommit_Python_VR_Spark/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_Python_VR_Spark/lastCompletedBuild/) | ---
   XLang | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Direct/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Direct/lastCompletedBuild/) | --- | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Flink/lastCompletedBuild/) | --- | [![Build Status](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PostCommit_XVR_Spark/lastCompletedBuild/) | ---
   
   Pre-Commit Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   
   --- |Java | Python | Go | Website | Whitespace
   --- | --- | --- | --- | --- | ---
   Non-portable | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Java_Cron/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Python_Cron/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Cron/lastCompletedBuild/)<br>[![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocker_Cron/lastCompletedBuild/) <br>[![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_PythonDocs_Cron/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/be
 am_PreCommit_Go_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Go_Cron/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Website_Cron/lastCompletedBuild/) | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Whitespace_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Whitespace_Cron/lastCompletedBuild/)
   Portable | --- | [![Build Status](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/badge/icon)](https://ci-beam.apache.org/job/beam_PreCommit_Portable_Python_Cron/lastCompletedBuild/) | --- | --- | ---
   
   See [.test-infra/jenkins/README](https://github.com/apache/beam/blob/master/.test-infra/jenkins/README.md) for trigger phrase, status and link of all Jenkins jobs.
   
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   ![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg)
   ![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg)
   ![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
y1chi commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r477646657



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       It is a bit confusing between self.event_time and self.event_timestamp,  I thought the timestamp was for debugging purpose that should be removed once it's not needed?




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
pabloem commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r476747902



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       The reason we collect the event_time metric is to know the start and end time of certain processing, right? If so, we only care about the beginning, and the end, right?
   Updating metrics are a bit of a slow operation to perform (not incredibly slow, but since this DoFn does nothing else), I think it may be a good idea to perform these updates in `finish_bundle` and `start_bundle` (for event_time, update only when the bundle started and ended, and for event_count, you can keep a member variable that counts the number of elements per bundle
   
   e.g.:
   ```
   start_bundle(self):
     self.element_counter = 0
     self.event_time.update(now)
   process(self, elm):
     self.element_counter += 1
     yield elm
   finish_bundle(self):
     self.event_time.update(now)
     self.element_count.inc(self.element_counter)
   ```
   wdyt?




----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.17%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.30%   -0.18%     
   ==========================================
     Files         685      695      +10     
     Lines       81519    82277     +758     
     Branches     9185     9297     +112     
   ==========================================
   + Hits        28109    28225     +116     
   - Misses      52987    53629     +642     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | [examples/snippets/snippets.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZXhhbXBsZXMvc25pcHBldHMvc25pcHBldHMucHk=) | `15.70% <0.00%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...0668d46](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] leiyiz commented on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
leiyiz commented on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679320648


   R: @y1chi 
   R: @pabloem 


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] commented on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/cfa448d121297398312d09c531258a72b413488b?el=desc) will **decrease** coverage by `0.15%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.47%   34.32%   -0.16%     
   ==========================================
     Files         684      693       +9     
     Lines       81483    82013     +530     
     Branches     9180     9268      +88     
   ==========================================
   + Hits        28090    28147      +57     
   - Misses      52965    53443     +478     
   + Partials      428      423       -5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [utils/interactive\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dXRpbHMvaW50ZXJhY3RpdmVfdXRpbHMucHk=) | `30.95% <0.00%> (-2.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | ... and [32 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...8c7eeb5](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
pabloem commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r477643983



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       I see. In that case, I think then there's not a big gain from using start_bundle and finish_bundle. I'll just approve it for now.




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
leiyiz commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r477489648



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       Yeah I think this makes sense, but I think I would need to keep updating some metric in the process method because I made a new metric for logging the timestamp of the events other than the now() metric




----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/cfa448d121297398312d09c531258a72b413488b?el=desc) will **decrease** coverage by `0.15%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.47%   34.32%   -0.16%     
   ==========================================
     Files         684      693       +9     
     Lines       81483    82013     +530     
     Branches     9180     9268      +88     
   ==========================================
   + Hits        28090    28147      +57     
   - Misses      52965    53443     +478     
   + Partials      428      423       -5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [utils/interactive\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dXRpbHMvaW50ZXJhY3RpdmVfdXRpbHMucHk=) | `30.95% <0.00%> (-2.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | ... and [32 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...8c7eeb5](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.18%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.29%   -0.19%     
   ==========================================
     Files         685      696      +11     
     Lines       81519    82307     +788     
     Branches     9185     9300     +115     
   ==========================================
   + Hits        28109    28228     +119     
   - Misses      52987    53656     +669     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [testing/load\_tests/load\_test\_metrics\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dGVzdGluZy9sb2FkX3Rlc3RzL2xvYWRfdGVzdF9tZXRyaWNzX3V0aWxzLnB5) | `34.98% <0.00%> (-1.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [dataframe/transforms\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZGF0YWZyYW1lL3RyYW5zZm9ybXNfdGVzdC5weQ==) | `25.00% <0.00%> (-0.21%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | ... and [30 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...f7a7ca7](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.16%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.32%   -0.17%     
   ==========================================
     Files         685      693       +8     
     Lines       81519    82013     +494     
     Branches     9185     9268      +83     
   ==========================================
   + Hits        28109    28147      +38     
   - Misses      52987    53443     +456     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | [examples/snippets/snippets.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZXhhbXBsZXMvc25pcHBldHMvc25pcHBldHMucHk=) | `15.70% <0.00%> (ø)` | |
   | ... and [23 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...0668d46](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
pabloem commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r478732717



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       @leiyiz thoughts?




----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.17%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.30%   -0.18%     
   ==========================================
     Files         685      695      +10     
     Lines       81519    82277     +758     
     Branches     9185     9297     +112     
   ==========================================
   + Hits        28109    28225     +116     
   - Misses      52987    53629     +642     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | [examples/snippets/snippets.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZXhhbXBsZXMvc25pcHBldHMvc25pcHBldHMucHk=) | `15.70% <0.00%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...0668d46](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
leiyiz commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r477468609



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       sounds very good




----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/cfa448d121297398312d09c531258a72b413488b?el=desc) will **decrease** coverage by `0.15%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.47%   34.32%   -0.16%     
   ==========================================
     Files         684      693       +9     
     Lines       81483    82013     +530     
     Branches     9180     9268      +88     
   ==========================================
   + Hits        28090    28147      +57     
   - Misses      52965    53443     +478     
   + Partials      428      423       -5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [utils/interactive\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dXRpbHMvaW50ZXJhY3RpdmVfdXRpbHMucHk=) | `30.95% <0.00%> (-2.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | ... and [32 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...8c7eeb5](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
leiyiz commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r475940875



##########
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:
       thanks!!




----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [beam] pabloem merged pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
pabloem merged pull request #12674:
URL: https://github.com/apache/beam/pull/12674


   


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.17%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.30%   -0.18%     
   ==========================================
     Files         685      695      +10     
     Lines       81519    82277     +758     
     Branches     9185     9297     +112     
   ==========================================
   + Hits        28109    28225     +116     
   - Misses      52987    53629     +642     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | [examples/snippets/snippets.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZXhhbXBsZXMvc25pcHBldHMvc25pcHBldHMucHk=) | `15.70% <0.00%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...f7a7ca7](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] leiyiz commented on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
leiyiz commented on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679423173


   Run Portable_Python PreCommit


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
leiyiz commented on a change in pull request #12674:
URL: https://github.com/apache/beam/pull/12674#discussion_r477468609



##########
File path: sdks/python/apache_beam/testing/benchmarks/nexmark/monitor.py
##########
@@ -0,0 +1,59 @@
+#
+# 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
+
+
+class Monitor(object):
+  """
+  A monitor of elements with support for later retrieving their metrics
+
+  monitor objects contains a doFn to record metrics
+
+  Args:
+    namespace: the namespace all metrics within this Monitor uses
+    name_prefix: a prefix for this Monitor's metrics' names, intended to
+      be unique in per-monitor basis in pipeline
+  """
+  def __init__(self, namespace, name_prefix):
+    # type: (str, str) -> None
+    self.namespace = namespace
+    self.name_prefix = name_prefix
+    self.doFn = MonitorDoFn(namespace, name_prefix)
+
+
+class MonitorDoFn(beam.DoFn):
+  def __init__(self, namespace, prefix):
+    self.element_count = Metrics.counter(
+        namespace, prefix + MonitorSuffix.ELEMENT_COUNTER)
+    self.event_time = Metrics.distribution(
+        namespace, prefix + MonitorSuffix.EVENT_TIME)
+
+  def process(self, element):
+    self.element_count.inc()
+    self.event_time.update(int(time() * 1000))
+    yield element

Review comment:
       sounds very good




----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.18%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.29%   -0.19%     
   ==========================================
     Files         685      696      +11     
     Lines       81519    82307     +788     
     Branches     9185     9300     +115     
   ==========================================
   + Hits        28109    28228     +119     
   - Misses      52987    53656     +669     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [testing/load\_tests/load\_test\_metrics\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dGVzdGluZy9sb2FkX3Rlc3RzL2xvYWRfdGVzdF9tZXRyaWNzX3V0aWxzLnB5) | `34.98% <0.00%> (-1.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [dataframe/transforms\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZGF0YWZyYW1lL3RyYW5zZm9ybXNfdGVzdC5weQ==) | `25.00% <0.00%> (-0.21%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | ... and [30 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...f7a7ca7](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.18%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.29%   -0.19%     
   ==========================================
     Files         685      696      +11     
     Lines       81519    82307     +788     
     Branches     9185     9300     +115     
   ==========================================
   + Hits        28109    28228     +119     
   - Misses      52987    53656     +669     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [testing/load\_tests/load\_test\_metrics\_utils.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dGVzdGluZy9sb2FkX3Rlc3RzL2xvYWRfdGVzdF9tZXRyaWNzX3V0aWxzLnB5) | `34.98% <0.00%> (-1.39%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [dataframe/transforms\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZGF0YWZyYW1lL3RyYW5zZm9ybXNfdGVzdC5weQ==) | `25.00% <0.00%> (-0.21%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | ... and [30 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...f7a7ca7](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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



[GitHub] [beam] codecov[bot] edited a comment on pull request #12674: [BEAM-8258] basic metric feature for nexmark

Posted by GitBox <gi...@apache.org>.
codecov[bot] edited a comment on pull request #12674:
URL: https://github.com/apache/beam/pull/12674#issuecomment-679334534


   # [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=h1) Report
   > Merging [#12674](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=desc) into [master](https://codecov.io/gh/apache/beam/commit/3e80a2113a4e06c9c1efe566b3db872cb96c8e91?el=desc) will **decrease** coverage by `0.17%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/beam/pull/12674/graphs/tree.svg?width=650&height=150&src=pr&token=qcbbAh8Fj1)](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #12674      +/-   ##
   ==========================================
   - Coverage   34.48%   34.30%   -0.18%     
   ==========================================
     Files         685      695      +10     
     Lines       81519    82277     +758     
     Branches     9185     9297     +112     
   ==========================================
   + Hits        28109    28225     +116     
   - Misses      52987    53629     +642     
     Partials      423      423              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [typehints/typecheck\_test\_py3.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVja190ZXN0X3B5My5weQ==) | `31.54% <0.00%> (-16.00%)` | :arrow_down: |
   | [typehints/typecheck.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHlwZWhpbnRzL3R5cGVjaGVjay5weQ==) | `29.44% <0.00%> (-6.18%)` | :arrow_down: |
   | [runners/worker/opcounters.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy93b3JrZXIvb3Bjb3VudGVycy5weQ==) | `33.81% <0.00%> (-0.87%)` | :arrow_down: |
   | [pipeline.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cGlwZWxpbmUucHk=) | `22.04% <0.00%> (-0.28%)` | :arrow_down: |
   | [io/gcp/bigquery\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-aW8vZ2NwL2JpZ3F1ZXJ5X3Rlc3QucHk=) | `27.39% <0.00%> (-0.18%)` | :arrow_down: |
   | [options/pipeline\_options.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-b3B0aW9ucy9waXBlbGluZV9vcHRpb25zLnB5) | `52.99% <0.00%> (-0.16%)` | :arrow_down: |
   | [transforms/ptransform\_test.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9wdHJhbnNmb3JtX3Rlc3QucHk=) | `18.37% <0.00%> (-0.09%)` | :arrow_down: |
   | [transforms/core.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-dHJhbnNmb3Jtcy9jb3JlLnB5) | `36.79% <0.00%> (-0.05%)` | :arrow_down: |
   | [runners/common.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-cnVubmVycy9jb21tb24ucHk=) | `27.50% <0.00%> (ø)` | |
   | [examples/snippets/snippets.py](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree#diff-ZXhhbXBsZXMvc25pcHBldHMvc25pcHBldHMucHk=) | `15.70% <0.00%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/beam/pull/12674/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=footer). Last update [66055db...0668d46](https://codecov.io/gh/apache/beam/pull/12674?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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