Skip to content

Bug: dimension value not being validated for empty strings or None #5526

Closed
@dreamorosi

Description

@dreamorosi

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

  1. Run the code above
  2. Observe that the EMF blob emitted has an empty dimension
  3. 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

Debugging logs

Metadata

Metadata

Labels

bugSomething isn't workingmetrics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions