This is an automated email from the ASF dual-hosted git repository.
damccorm 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 bc0b2609a6d Return a useful error when we fail to create a
MonitoringInfo object (#27722)
bc0b2609a6d is described below
commit bc0b2609a6d75246fd7ea03ea61822d8fb11fa40
Author: Danny McCormick <[email protected]>
AuthorDate: Fri Jul 28 09:18:30 2023 -0400
Return a useful error when we fail to create a MonitoringInfo object
(#27722)
* Return a useful error when we fail to create a MonitoringInfo object
* Exception -> RuntimeError
---
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..ae12c93a571 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 RuntimeError(
+ f'Failed to create MonitoringInfo for urn {urn} type {type} labels ' +
+ '{labels} and payload {payload}') from e
def is_counter(monitoring_info_proto):