-
Notifications
You must be signed in to change notification settings - Fork 522
Refactor Gauge metrics to be homeserver-scoped
#18725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
b14eed7
4bb84a6
80d5fd5
1504100
608f72e
0a2877e
0c93d85
fe1a16f
944df9c
54e2374
883062b
90efa41
f4b6d35
656c3ad
c55e615
0fd34a6
563f543
554d588
2536aaf
7b55ffb
68061f9
d587aa9
def4eb5
650ce32
4387262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Refactor `Gauge` metrics to be homeserver-scoped. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ | |
| tag_args, | ||
| trace, | ||
| ) | ||
| from synapse.metrics import SERVER_NAME_LABEL | ||
| from synapse.metrics.background_process_metrics import wrap_as_background_process | ||
| from synapse.replication.http.federation import ( | ||
| ReplicationFederationSendEduRestServlet, | ||
|
|
@@ -120,7 +121,7 @@ | |
| last_pdu_ts_metric = Gauge( | ||
| "synapse_federation_last_received_pdu_time", | ||
| "The timestamp of the last PDU which was successfully received from the given domain", | ||
| labelnames=("server_name",), | ||
| labelnames=("origin_server_name", SERVER_NAME_LABEL), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This metric was already using the |
||
| ) | ||
|
|
||
|
|
||
|
|
@@ -545,7 +546,9 @@ async def process_pdu(pdu: EventBase) -> JsonDict: | |
| ) | ||
|
|
||
| if newest_pdu_ts and origin in self._federation_metrics_domains: | ||
| last_pdu_ts_metric.labels(server_name=origin).set(newest_pdu_ts / 1000) | ||
| last_pdu_ts_metric.labels( | ||
| origin_server_name=origin, **{SERVER_NAME_LABEL: self.server_name} | ||
| ).set(newest_pdu_ts / 1000) | ||
|
MadLittleMods marked this conversation as resolved.
|
||
|
|
||
| return pdu_results | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| tags, | ||
| whitelisted_homeserver, | ||
| ) | ||
| from synapse.metrics import SERVER_NAME_LABEL | ||
| from synapse.types import JsonDict | ||
| from synapse.util import json_decoder | ||
| from synapse.util.metrics import measure_func | ||
|
|
@@ -47,7 +48,7 @@ | |
| last_pdu_ts_metric = Gauge( | ||
| "synapse_federation_last_sent_pdu_time", | ||
| "The timestamp of the last PDU which was successfully sent to the given domain", | ||
| labelnames=("server_name",), | ||
| labelnames=("destination_server_name", SERVER_NAME_LABEL), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This metric was already using the |
||
| ) | ||
|
|
||
|
|
||
|
|
@@ -191,6 +192,7 @@ def json_data_cb() -> JsonDict: | |
|
|
||
| if pdus and destination in self._federation_metrics_domains: | ||
| last_pdu = pdus[-1] | ||
| last_pdu_ts_metric.labels(server_name=destination).set( | ||
| last_pdu.origin_server_ts / 1000 | ||
| ) | ||
| last_pdu_ts_metric.labels( | ||
| destination_server_name=destination, | ||
| **{SERVER_NAME_LABEL: self.server_name}, | ||
| ).set(last_pdu.origin_server_ts / 1000) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this lint!
This should make maintenance of these changes much more manageable going forward.