From ee262ef0c10aa28f7dce4ae969e6b783abf08414 Mon Sep 17 00:00:00 2001 From: Vittorio Polverino Date: Tue, 3 Jun 2025 13:17:23 +0200 Subject: [PATCH] refactor: reduce max number of allowed labels in counters from 8 to 6 --- localstack-core/localstack/utils/analytics/metrics.py | 4 ++-- tests/unit/utils/analytics/test_metrics.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/localstack-core/localstack/utils/analytics/metrics.py b/localstack-core/localstack/utils/analytics/metrics.py index e0fa8d47048d9..87a52e593547e 100644 --- a/localstack-core/localstack/utils/analytics/metrics.py +++ b/localstack-core/localstack/utils/analytics/metrics.py @@ -259,8 +259,8 @@ def __init__(self, namespace: str, name: str, labels: list[str]): if any(not label for label in labels): raise ValueError("Labels must be non-empty strings.") - if len(labels) > 8: - raise ValueError("A maximum of 8 labels are allowed.") + if len(labels) > 6: + raise ValueError("Too many labels: counters allow a maximum of 6.") self._type = "counter" self._labels = labels diff --git a/tests/unit/utils/analytics/test_metrics.py b/tests/unit/utils/analytics/test_metrics.py index bad18c47657a0..cc15499768381 100644 --- a/tests/unit/utils/analytics/test_metrics.py +++ b/tests/unit/utils/analytics/test_metrics.py @@ -137,11 +137,11 @@ def increment(): def test_max_labels_limit(): - with pytest.raises(ValueError, match="A maximum of 8 labels are allowed."): + with pytest.raises(ValueError, match="Too many labels: counters allow a maximum of 6."): Counter( namespace="test_namespace", name="test_counter", - labels=["l1", "l2", "l3", "l4", "l5", "l6", "l7", "l8", "l9"], + labels=["l1", "l2", "l3", "l4", "l5", "l6", "l7"], )