Closed
Description
Expected Behaviour
When adding a dimension to my metrics, I should get a warning if the dimension value is invalid aka an empty string (""
) or None
, and the dimension should not be added to the EMF blobs emitted by the utility.
Current Behaviour
Currently the utility doesn't validate the input and generates an EMF blob with the invalid dimension.
Code snippet
metrics = Metrics()
metrics.add_dimension("my_dim","") # THIS
metrics.add_metrics(...)
metrics.flush..
Possible Solution
We should: 1/ validate the input when adding a dimension, 2/ emit a warning if invalid, and 3/ don't add the dimension to the EMF blob
Steps to Reproduce
- Run the code above
- Observe that the EMF blob emitted has an empty dimension
- Verify that the processed metric in CloudWatch does not include any dimensions
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.8
Packaging format used
PyPi