Refactor Gauge metrics to be homeserver-scoped#18725
Conversation
``` synapse/metrics/__init__.py:522: error: Expected the `labelnames` argument of Histogram to be a list of label names (including `SERVER_NAME_LABEL`), but got TupleExpr:528( StrExpr(type) StrExpr(reason) NameExpr(SERVER_NAME_LABEL [synapse.metrics.SERVER_NAME_LABEL])). If this is a process-level metric (vs homeserver-level), use a type ignore comment to disable this check. [missing-server-name-label] ```
| "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), |
There was a problem hiding this comment.
This metric was already using the server_name label so I've had to rename the label. I've updated the contrib/grafana/synapse.json but it's something we probably want to call out in the upgrade notes (added)
| "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), |
There was a problem hiding this comment.
This metric was already using the server_name label so I've had to rename the label. I've updated the contrib/grafana/synapse.json but it's something we probably want to call out in the upgrade notes (added)
18de228 to
6b308e6
Compare
6b308e6 to
0fd34a6
Compare
devonh
left a comment
There was a problem hiding this comment.
Other than the small fixes and the comment about argument consistency, these changes seem pretty straightforward.
| return None | ||
|
|
||
|
|
||
| def check_prometheus_metric_instantiation(ctx: FunctionSigContext) -> CallableType: |
There was a problem hiding this comment.
Thank you for adding this lint!
This should make maintenance of these changes much more manageable going forward.
Conflicts: scripts-dev/mypy_synapse_plugin.py
|
Thanks for the review @devonh 🐬 |
Bulk refactor
Gaugemetrics to be homeserver-scoped. We also add lints to make sure that newGaugemetrics don't sneak in without using theserver_namelabel (SERVER_NAME_LABEL).Part of #18592
Testing strategy
metricslistener in yourhomeserver.yamlpoetry run synapse_homeserver --config-path homeserver.yamlhttp://localhost:9322/_synapse/metricsand/orhttp://localhost:9323/metricsserver_namelabelPull Request Checklist
EventStoretoEventWorkerStore.".code blocks.