You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2020/08/13 23:09:07 UTC

[beam] branch master updated: fix logic issue in metric name namespace filtering (#12570)

This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new b423fe3  fix logic issue in metric name namespace filtering (#12570)
b423fe3 is described below

commit b423fe30f950b66b9cc1397776c8ea6cd1af7324
Author: Leiyi Zhang <35...@users.noreply.github.com>
AuthorDate: Thu Aug 13 16:08:47 2020 -0700

    fix logic issue in metric name namespace filtering (#12570)
    
    * fix logic issue in metric name namespace filtering
    
    * refactor boolean logic to be more concise
    
    Co-authored-by: Leiyi Zhang <le...@google.com>
---
 sdks/python/apache_beam/metrics/metric.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/sdks/python/apache_beam/metrics/metric.py b/sdks/python/apache_beam/metrics/metric.py
index 4b5a2a5..1c68ad9 100644
--- a/sdks/python/apache_beam/metrics/metric.py
+++ b/sdks/python/apache_beam/metrics/metric.py
@@ -127,13 +127,12 @@ class MetricResults(object):
 
   @staticmethod
   def _matches_name(filter, metric_key):
-    if not filter.names and not filter.namespaces:
-      return True
-
-    if ((filter.namespaces and metric_key.metric.namespace in filter.namespaces)
-        or (filter.names and metric_key.metric.name in filter.names)):
+    if ((filter.namespaces and
+         metric_key.metric.namespace not in filter.namespaces) or
+        (filter.names and metric_key.metric.name not in filter.names)):
+      return False
+    else:
       return True
-    return False
 
   @staticmethod
   def _is_sub_list(needle, haystack):