Skip to content

Commit 4c6cb11

Browse files
authored
fix MeterId class name references, for consistency (#77)
1 parent 89d189f commit 4c6cb11

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

spectator/meter/meter_id.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def _validate_tags(self, tags: Dict[str, str]) -> Dict[str, str]:
2424
valid_tags = validate_tags(tags)
2525

2626
if valid_tags != tags:
27-
msg = "Id(name=%s, tags=%s) is invalid due to tag keys or values which are not strings " \
28-
"or are zero-length strings; proceeding with truncated tags Id(name=%s, tags=%s)"
27+
msg = "MeterId(name=%s, tags=%s) is invalid due to tag keys or values which are not strings " \
28+
"or are zero-length strings; proceeding with truncated tags MeterId(name=%s, tags=%s)"
2929
self._logger.warning(msg, self._name, tags, self._name, valid_tags)
3030

3131
return valid_tags
@@ -70,4 +70,4 @@ def __eq__(self, other) -> bool:
7070
return False
7171

7272
def __str__(self) -> str:
73-
return f"Id(name={self._name}, tags={self._tags})"
73+
return f"MeterId(name={self._name}, tags={self._tags})"

tests/meter/test_meter_id.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ def test_illegal_chars_are_replaced(self):
3030

3131
def test_invalid_tags(self):
3232
expected_messages = [
33-
"WARNING:spectator.meter.meter_id:Id(name=foo, tags={'k': ''}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags Id(name=foo, tags={})",
34-
"WARNING:spectator.meter.meter_id:Id(name=bar, tags={'k': 1}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags Id(name=bar, tags={})",
35-
"WARNING:spectator.meter.meter_id:Id(name=baz, tags={1: 'v'}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags Id(name=baz, tags={})",
36-
"WARNING:spectator.meter.meter_id:Id(name=quux, tags={'k': 'v', 1: 'v'}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags Id(name=quux, tags={'k': 'v'})",
33+
"WARNING:spectator.meter.meter_id:MeterId(name=foo, tags={'k': ''}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags MeterId(name=foo, tags={})",
34+
"WARNING:spectator.meter.meter_id:MeterId(name=bar, tags={'k': 1}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags MeterId(name=bar, tags={})",
35+
"WARNING:spectator.meter.meter_id:MeterId(name=baz, tags={1: 'v'}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags MeterId(name=baz, tags={})",
36+
"WARNING:spectator.meter.meter_id:MeterId(name=quux, tags={'k': 'v', 1: 'v'}) is invalid due to tag keys or values which are not strings or are zero-length strings; proceeding with truncated tags MeterId(name=quux, tags={'k': 'v'})",
3737
]
3838

3939
with self.assertLogs("spectator.meter.meter_id", level='INFO') as logs:
4040
id1 = MeterId("foo", {"k": ""})
41-
self.assertEqual("Id(name=foo, tags={})", str(id1))
41+
self.assertEqual("MeterId(name=foo, tags={})", str(id1))
4242
id2 = MeterId("bar", {"k": 1})
43-
self.assertEqual("Id(name=bar, tags={})", str(id2))
43+
self.assertEqual("MeterId(name=bar, tags={})", str(id2))
4444
id3 = MeterId("baz", {1: "v"})
45-
self.assertEqual("Id(name=baz, tags={})", str(id3))
45+
self.assertEqual("MeterId(name=baz, tags={})", str(id3))
4646
id4 = MeterId("quux", {"k": "v", 1: "v"})
47-
self.assertEqual("Id(name=quux, tags={'k': 'v'})", str(id4))
47+
self.assertEqual("MeterId(name=quux, tags={'k': 'v'})", str(id4))
4848

4949
self.assertEqual(expected_messages, logs.output)
5050

@@ -70,13 +70,13 @@ def test_spectatord_id(self):
7070

7171
def test_str(self):
7272
id1 = MeterId("foo")
73-
self.assertEqual("Id(name=foo, tags={})", str(id1))
73+
self.assertEqual("MeterId(name=foo, tags={})", str(id1))
7474

7575
id2 = MeterId("bar", {"a": "1"})
76-
self.assertEqual("Id(name=bar, tags={'a': '1'})", str(id2))
76+
self.assertEqual("MeterId(name=bar, tags={'a': '1'})", str(id2))
7777

78-
id3 = MeterId("bar", {"a": "1", "b": "2", "c": "3"})
79-
self.assertEqual("Id(name=bar, tags={'a': '1', 'b': '2', 'c': '3'})", str(id3))
78+
id3 = MeterId("baz", {"a": "1", "b": "2", "c": "3"})
79+
self.assertEqual("MeterId(name=baz, tags={'a': '1', 'b': '2', 'c': '3'})", str(id3))
8080

8181
def test_tags(self):
8282
id1 = MeterId("foo", {"a": "1"})

tests/test_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ def test_monotonic_counter_with_id(self):
170170
def test_new_id(self):
171171
r1 = Registry(Config("memory"))
172172
id1 = r1.new_id("id")
173-
self.assertEqual("Id(name=id, tags={})", str(id1))
173+
self.assertEqual("MeterId(name=id, tags={})", str(id1))
174174

175175
r2 = Registry(Config("memory", {"extra-tags": "foo"}))
176176
id2 = r2.new_id("id")
177-
self.assertEqual("Id(name=id, tags={'extra-tags': 'foo'})", str(id2))
177+
self.assertEqual("MeterId(name=id, tags={'extra-tags': 'foo'})", str(id2))
178178

179179
def test_pct_distribution_summary(self):
180180
r = Registry(Config("memory"))

0 commit comments

Comments
 (0)