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 <[email protected]> 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):
