Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7a7b5f

Browse files
refactor: reduce max number of allowed labels in counters [DAT-146] (#12704)
1 parent db447dd commit a7a7b5f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎localstack-core/localstack/utils/analytics/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def __init__(self, namespace: str, name: str, labels: list[str]):
259259
if any(not label for label in labels):
260260
raise ValueError("Labels must be non-empty strings.")
261261

262-
if len(labels) > 8:
263-
raise ValueError("A maximum of 8 labels are allowed.")
262+
if len(labels) > 6:
263+
raise ValueError("Too many labels: counters allow a maximum of 6.")
264264

265265
self._type = "counter"
266266
self._labels = labels

‎tests/unit/utils/analytics/test_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ def increment():
137137

138138

139139
def test_max_labels_limit():
140-
with pytest.raises(ValueError, match="A maximum of 8 labels are allowed."):
140+
with pytest.raises(ValueError, match="Too many labels: counters allow a maximum of 6."):
141141
Counter(
142142
namespace="test_namespace",
143143
name="test_counter",
144-
labels=["l1", "l2", "l3", "l4", "l5", "l6", "l7", "l8", "l9"],
144+
labels=["l1", "l2", "l3", "l4", "l5", "l6", "l7"],
145145
)
146146

147147

0 commit comments

Comments
 (0)