You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by da...@apache.org on 2023/07/27 20:31:51 UTC
[beam] 01/01: Return a useful error when we fail to create a MonitoringInfo object
This is an automated email from the ASF dual-hosted git repository.
damccorm pushed a commit to branch users/damccorm/metricError
in repository https://gitbox.apache.org/repos/asf/beam.git
commit 1b3d3f36076700dbc1ebc0badf69bb5ce16138ba
Author: Danny McCormick <da...@google.com>
AuthorDate: Thu Jul 27 16:31:35 2023 -0400
Return a useful error when we fail to create a MonitoringInfo object
---
sdks/python/apache_beam/metrics/monitoring_infos.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sdks/python/apache_beam/metrics/monitoring_infos.py b/sdks/python/apache_beam/metrics/monitoring_infos.py
index ed7f952cf8e..99e9fbaecef 100644
--- a/sdks/python/apache_beam/metrics/monitoring_infos.py
+++ b/sdks/python/apache_beam/metrics/monitoring_infos.py
@@ -299,8 +299,13 @@ def create_monitoring_info(urn, type_urn, payload, labels=None):
payload: The payload field to use in the monitoring info.
labels: The label dictionary to use in the MonitoringInfo.
"""
- return metrics_pb2.MonitoringInfo(
- urn=urn, type=type_urn, labels=labels or {}, payload=payload)
+ try:
+ return metrics_pb2.MonitoringInfo(
+ urn=urn, type=type_urn, labels=labels or {}, payload=payload)
+ except TypeError as e:
+ raise Exception(
+ f'Failed to create MonitoringInfo for urn {urn} type {type} labels ' +
+ '{labels} and payload {payload}') from e
def is_counter(monitoring_info_proto):