Skip to content

Commit 7d40873

Browse files
committed
Fill in synapse/util/ratelimitutils.py
Wait for #18656 to merge so we have access to `self.server_name`
1 parent 8876aa8 commit 7d40873

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

synapse/util/ratelimitutils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
run_in_background,
5353
)
5454
from synapse.logging.opentracing import start_active_span
55-
from synapse.metrics import Histogram, LaterGauge
55+
from synapse.metrics import SERVER_NAME_LABEL, Histogram, LaterGauge
5656
from synapse.util import Clock
5757

5858
if typing.TYPE_CHECKING:
@@ -75,7 +75,7 @@
7575
queue_wait_timer = Histogram(
7676
"synapse_rate_limit_queue_wait_time_seconds",
7777
"Amount of time spent waiting for the rate limiter to let our request through.",
78-
["rate_limiter_name"],
78+
labelnames=["rate_limiter_name", SERVER_NAME_LABEL],
7979
buckets=(
8080
0.005,
8181
0.01,
@@ -279,7 +279,10 @@ def should_sleep(self) -> bool:
279279
async def _on_enter_with_tracing(self, request_id: object) -> None:
280280
maybe_metrics_cm: ContextManager = contextlib.nullcontext()
281281
if self.metrics_name:
282-
maybe_metrics_cm = queue_wait_timer.labels(self.metrics_name).time()
282+
maybe_metrics_cm = queue_wait_timer.labels(
283+
rate_limiter_name=self.metrics_name,
284+
**{SERVER_NAME_LABEL: self.server_name},
285+
).time()
283286
with start_active_span("ratelimit wait"), maybe_metrics_cm:
284287
await self._on_enter(request_id)
285288

0 commit comments

Comments
 (0)