Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 676ea6d

Browse files
committed
Convert labels to str ourselves
This is done internally (if you read the code) but the type annotations now require str.
1 parent 74e4419 commit 676ea6d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

synapse/handlers/register.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def init_counters_for_auth_provider(auth_provider_id: str) -> None:
6868
until the user first logs in/registers.
6969
"""
7070
for is_guest in (True, False):
71-
login_counter.labels(guest=is_guest, auth_provider=auth_provider_id)
71+
login_counter.labels(guest=str(is_guest), auth_provider=auth_provider_id)
7272
for shadow_banned in (True, False):
7373
registration_counter.labels(
74-
guest=is_guest,
75-
shadow_banned=shadow_banned,
74+
guest=str(is_guest),
75+
shadow_banned=str(shadow_banned),
7676
auth_provider=auth_provider_id,
7777
)
7878

@@ -341,8 +341,8 @@ async def register_user(
341341
fail_count += 1
342342

343343
registration_counter.labels(
344-
guest=make_guest,
345-
shadow_banned=shadow_banned,
344+
guest=str(make_guest),
345+
shadow_banned=str(shadow_banned),
346346
auth_provider=(auth_provider_id or ""),
347347
).inc()
348348

@@ -775,7 +775,7 @@ async def register_device(
775775
)
776776

777777
login_counter.labels(
778-
guest=is_guest,
778+
guest=str(is_guest),
779779
auth_provider=(auth_provider_id or ""),
780780
).inc()
781781

synapse/metrics/_gc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def _maybe_gc() -> None:
123123

124124
_last_gc[i] = end
125125

126-
gc_time.labels(i).observe(end - start)
127-
gc_unreachable.labels(i).set(unreachable)
126+
gc_time.labels(str(i)).observe(end - start)
127+
gc_unreachable.labels(str(i)).set(unreachable)
128128

129129
gc_task = task.LoopingCall(_maybe_gc)
130130
gc_task.start(0.1)

synapse/replication/http/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ async def send_request(*, instance_name="master", **kwargs):
257257
# We convert to SynapseError as we know that it was a SynapseError
258258
# on the main process that we should send to the client. (And
259259
# importantly, not stack traces everywhere)
260-
_outgoing_request_counter.labels(cls.NAME, e.code).inc()
260+
_outgoing_request_counter.labels(cls.NAME, str(e.code)).inc()
261261
raise e.to_synapse_error()
262262
except Exception as e:
263263
_outgoing_request_counter.labels(cls.NAME, "ERR").inc()
264264
raise SynapseError(502, "Failed to talk to main process") from e
265265

266-
_outgoing_request_counter.labels(cls.NAME, 200).inc()
266+
_outgoing_request_counter.labels(cls.NAME, "200").inc()
267267
return result
268268

269269
return send_request

synapse/replication/tcp/external_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def get(self, cache_name: str, key: str) -> Optional[Any]:
115115

116116
logger.debug("Got cache result %s %s: %r", cache_name, key, result)
117117

118-
get_counter.labels(cache_name, result is not None).inc()
118+
get_counter.labels(cache_name, str(result is not None)).inc()
119119

120120
if not result:
121121
return None

0 commit comments

Comments
 (0)