Fix cache metrics to collect from all servers#18748
Merged
MadLittleMods merged 5 commits intodevelopfrom Aug 1, 2025
Merged
Conversation
MadLittleMods
commented
Jul 30, 2025
| # just before they are returned from the scrape endpoint. | ||
| CACHE_METRIC_REGISTRY = DynamicCollectorRegistry() | ||
|
|
||
| caches_by_name: Dict[str, Sized] = {} |
Contributor
Author
There was a problem hiding this comment.
Removed because it was unused
Same changelog as #18604 so they merge
MadLittleMods
commented
Jul 30, 2025
| @@ -0,0 +1 @@ | |||
| Refactor cache metrics to be homeserver-scoped. | |||
devonh
approved these changes
Aug 1, 2025
Contributor
Author
|
Thanks for the review @devonh 🐠 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix cache metrics to collect from all servers
Follow-up to #18604
Previously, our cache metrics did include the
server_namelabel as expected but we were only seeing the last server being reported. This was caused because we wouldCACHE_METRIC_REGISTRY.register_hook(metric_name, metric.collect)where themetric_nameonly 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_nameso 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 repo that sanity check all metrics to ensure that we can see each metric includes data from multiple servers.
Testing strategy
(see
test_cache_metric_multiple_serversthat was added in this PR)Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.