Skip to content

Commit 9dc8bf8

Browse files
Strip empty chars
1 parent 8744555 commit 9dc8bf8

File tree

1 file changed

+3
-1
lines changed
  • aws_lambda_powertools/metrics/provider/cloudwatch_emf

1 file changed

+3
-1
lines changed

aws_lambda_powertools/metrics/provider/cloudwatch_emf/cloudwatch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ def add_dimension(self, name: str, value: str) -> None:
273273
f"Maximum number of dimensions exceeded ({MAX_DIMENSIONS}): Unable to add dimension {name}.",
274274
)
275275

276+
value = value if isinstance(value, str) else str(value)
277+
276278
if not name.strip() or not value.strip():
277279
warnings.warn(
278280
f"The dimension {name} doesn't meet the requirements and won't be added. "
@@ -283,7 +285,7 @@ def add_dimension(self, name: str, value: str) -> None:
283285
# Cast value to str according to EMF spec
284286
# Majority of values are expected to be string already, so
285287
# checking before casting improves performance in most cases
286-
self.dimension_set[name] = value if isinstance(value, str) else str(value)
288+
self.dimension_set[name] = value
287289

288290
def add_metadata(self, key: str, value: Any) -> None:
289291
"""Adds high cardinal metadata for metrics object

0 commit comments

Comments
 (0)