Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aws_lambda_powertools/metrics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger = logging.getLogger(__name__)

MAX_METRICS = 100
MAX_DIMENSIONS = 9
MAX_DIMENSIONS = 29


class MetricUnit(Enum):
Expand Down Expand Up @@ -233,7 +233,7 @@ def add_dimension(self, name: str, value: str) -> None:
Dimension value
"""
logger.debug(f"Adding dimension: {name}:{value}")
if len(self.dimension_set) == 9:
if len(self.dimension_set) == MAX_DIMENSIONS:
raise SchemaValidationError(
f"Maximum number of dimensions exceeded ({MAX_DIMENSIONS}): Unable to add dimension {name}."
)
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def test_schema_no_metrics(service, namespace):


def test_exceed_number_of_dimensions(metric, namespace):
# GIVEN we have more dimensions than CloudWatch supports
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(11)]
# GIVEN we have more dimensions than CloudWatch supports (N+1)
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(31)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, let's start using the constant MAX_DIMENSIONS so these can be updated/failed accordingly?


# WHEN we attempt to serialize them into a valid EMF object
# THEN it should fail validation and raise SchemaValidationError
Expand All @@ -332,9 +332,9 @@ def test_exceed_number_of_dimensions(metric, namespace):


def test_exceed_number_of_dimensions_with_service(metric, namespace, monkeypatch):
# GIVEN we have service set and add more dimensions than CloudWatch supports (N+1)
# GIVEN we have service set and add more dimensions than CloudWatch supports (N-1)
monkeypatch.setenv("POWERTOOLS_SERVICE_NAME", "test_service")
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(9)]
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(29)]

# WHEN we attempt to serialize them into a valid EMF object
# THEN it should fail validation and raise SchemaValidationError
Expand Down