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

Commit 9385c41

Browse files
Fix Prometheus metrics being negative (mixed up start/end) (#13584)
Fix: - #13535 (comment) - #13533 (comment)
1 parent 3dd175b commit 9385c41

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

changelog.d/13584.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add metrics to time how long it takes us to do backfill processing (`synapse_federation_backfill_processing_before_time_seconds`, `synapse_federation_backfill_processing_after_time_seconds`).

synapse/handlers/federation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@
8686
"sec",
8787
[],
8888
buckets=(
89+
0.1,
90+
0.5,
8991
1.0,
92+
2.5,
9093
5.0,
94+
7.5,
9195
10.0,
96+
15.0,
9297
20.0,
9398
30.0,
9499
40.0,
@@ -482,7 +487,7 @@ async def try_backfill(domains: List[str]) -> bool:
482487

483488
processing_end_time = self.clock.time_msec()
484489
backfill_processing_before_timer.observe(
485-
(processing_start_time - processing_end_time) / 1000
490+
(processing_end_time - processing_start_time) / 1000
486491
)
487492

488493
success = await try_backfill(likely_domains)

synapse/handlers/federation_event.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,25 @@
104104
"sec",
105105
[],
106106
buckets=(
107+
0.1,
108+
0.25,
109+
0.5,
107110
1.0,
111+
2.5,
108112
5.0,
113+
7.5,
109114
10.0,
115+
15.0,
110116
20.0,
117+
25.0,
111118
30.0,
112119
40.0,
120+
50.0,
113121
60.0,
114122
80.0,
123+
100.0,
115124
120.0,
125+
150.0,
116126
180.0,
117127
"+Inf",
118128
),

synapse/rest/client/room.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ def from_member_count(member_count: int) -> "_RoomSize":
116116
2.5,
117117
5.0,
118118
10.0,
119+
20.0,
119120
30.0,
120121
60.0,
122+
80.0,
123+
100.0,
121124
120.0,
125+
150.0,
122126
180.0,
123127
"+Inf",
124128
),
@@ -674,7 +678,7 @@ async def on_GET(
674678
room_member_count = await make_deferred_yieldable(room_member_count_deferred)
675679
messsages_response_timer.labels(
676680
room_size=_RoomSize.from_member_count(room_member_count)
677-
).observe((processing_start_time - processing_end_time) / 1000)
681+
).observe((processing_end_time - processing_start_time) / 1000)
678682

679683
return 200, msgs
680684

0 commit comments

Comments
 (0)