Skip to content

chore(metrics): revert dimensions test and split #1243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
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
17 changes: 14 additions & 3 deletions tests/functional/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,20 @@ def test_schema_no_metrics(service, namespace):
my_metrics.serialize_metric_set()


def test_exceed_number_of_dimensions(metric, namespace, monkeypatch):
# GIVEN we we have more dimensions than CloudWatch supports
# and that service dimension is injected like a user-defined dimension (N+1)
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)]

# WHEN we attempt to serialize them into a valid EMF object
# THEN it should fail validation and raise SchemaValidationError
with pytest.raises(SchemaValidationError, match="Maximum number of dimensions exceeded.*"):
with single_metric(**metric, namespace=namespace) as my_metric:
for dimension in dimensions:
my_metric.add_dimension(**dimension)


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)
monkeypatch.setenv("POWERTOOLS_SERVICE_NAME", "test_service")
dimensions = [{"name": f"test_{i}", "value": "test"} for i in range(9)]

Expand Down