From 3cc55d0891ddc06aec9844aa499356ab503ef80e Mon Sep 17 00:00:00 2001 From: Ali Ebrahim Date: Mon, 9 Jan 2023 22:35:12 -0800 Subject: [PATCH] Add attribute name to type warning message. Without this, the error message simply specifies that some attribute has the incorrect type, but this is very difficult to debug without knowing which attribute it was. --- opentelemetry-api/src/opentelemetry/attributes/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opentelemetry-api/src/opentelemetry/attributes/__init__.py b/opentelemetry-api/src/opentelemetry/attributes/__init__.py index 20d9ae91e1d..0b7d056da99 100644 --- a/opentelemetry-api/src/opentelemetry/attributes/__init__.py +++ b/opentelemetry-api/src/opentelemetry/attributes/__init__.py @@ -97,9 +97,10 @@ def _clean_attribute( return tuple(cleaned_seq) _logger.warning( - "Invalid type %s for attribute value. Expected one of %s or a " + "Invalid type %s for attribute '%s' value. Expected one of %s or a " "sequence of those types", type(value).__name__, + key, [valid_type.__name__ for valid_type in _VALID_ATTR_VALUE_TYPES], ) return None