synapse/tests/metrics
Eric Eastwood e43a1cec84
Fix cache metrics to collect from all servers (#18748)
Follow-up to https://github.com/element-hq/synapse/pull/18604

Previously, our cache metrics did include the `server_name` label as
expected but we were only seeing the last server being reported. This
was caused because we would
`CACHE_METRIC_REGISTRY.register_hook(metric_name, metric.collect)` where
the `metric_name` only took into account the cache name so it would be
overwritten every time we spawn a new server.

This PR updates the register logic to include the `server_name` so we
have a hook for every cache on every server as expected.

I noticed this problem thanks to some [tests in the Synapse Pro for
Small Hosts](https://github.com/element-hq/synapse-small-hosts/pull/173)
repo that sanity check all metrics to ensure that we can see each metric
includes data from multiple servers.
2025-08-01 12:29:58 -05:00
..
__init__.py Avoid incrementing bg process utime/stime counters by negative durations (#14323) 2022-10-31 13:02:07 +00:00
test_background_process_metrics.py Refactor background process metrics to be homeserver-scoped (#18670) 2025-07-23 13:28:17 -05:00
test_metrics.py Fix cache metrics to collect from all servers (#18748) 2025-08-01 12:29:58 -05:00
test_phone_home_stats.py Use twisted.internet.testing module in tests instead of deprecated twisted.test.proto_helpers. (#18728) 2025-07-30 12:32:10 +01:00