github-actions[bot] commented on code in PR #41084:
URL: https://github.com/apache/beam/pull/41084#discussion_r4506288104


##########
sdks/python/apache_beam/runners/dataflow/dataflow_metrics.py:
##########
@@ -185,8 +185,8 @@ def _populate_metrics(self, response, result, 
user_metrics=False):
 
     # Now we create the MetricResult elements.
     for metric_key, metric in metrics_by_name.items():
-      attempted = self._get_metric_value(metric['tentative'])
-      committed = self._get_metric_value(metric['committed'])
+      attempted = self._get_metric_value(metric.get('tentative'))

Review Comment:
   **🟠 High**: When `metric.get('tentative')` is `None` (a committed-only 
metric), `attempted` becomes `None`. However, `DataflowMetrics.query()` filters 
results using `_is_counter`, `_is_distribution`, and `_is_string_set` (lines 
85-95), all of which only check `isinstance(metric_result.attempted, ...)`. As 
a result, committed-only metrics no longer raise `KeyError`, but they are 
silently dropped from `query()` results.
   
   Please update `_is_counter`, `_is_distribution`, and `_is_string_set` to 
also check `metric_result.committed` (e.g., 
`isinstance(metric_result.attempted, numbers.Number) or 
isinstance(metric_result.committed, numbers.Number)`), and add an assertion in 
`dataflow_metrics_test.py` verifying `DataflowMetrics.query()` returns 
committed-only metrics.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to