Use homeserver specific Prometheus CollectorRegistry for metrics instead of global REGISTRY#18443
Closed
MadLittleMods wants to merge 42 commits intodevelopfrom
Closed
Use homeserver specific Prometheus CollectorRegistry for metrics instead of global REGISTRY#18443MadLittleMods wants to merge 42 commits intodevelopfrom
CollectorRegistry for metrics instead of global REGISTRY#18443MadLittleMods wants to merge 42 commits intodevelopfrom
Conversation
…lector_registry`
CollectorRegistry for metrics instead of using global REGISTRYCollectorRegistry for metrics instead of global REGISTRY
Conflicts: synapse/app/generic_worker.py synapse/app/homeserver.py
This reverts commit 4a5c2f8.
Conflicts: docs/usage/configuration/config_documentation.md synapse/module_api/callbacks/spamchecker_callbacks.py
From my review of #18416
Conflicts: synapse/metrics/__init__.py
This was referenced Jun 20, 2025
Contributor
Author
|
Closing in favor of the smaller PRs that target #18592 |
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.
Use homeserver specific Prometheus
CollectorRegistry(hs.metrics_collector_registry) for metrics instead of globalREGISTRYwhich can be polluted with whatever other code/libraries that are running in the same Python process that also use the defaultREGISTRY.This is specifically spawning from running multiple Synapse in the same Python process and wanting separate metrics.
Other breaking changes:
metricslistener in favor of our standardhttplistener with themetricsresourceInitial exploration for #18592
Todo
Update: This is now better tracked by #18592
_set_prometheus_client_use_created_metricsis used with the new path (PrometheusMetricsHackTestCase)registry=hs.metrics_collector_registryCounterHistogramGaugeSummaryInfoEnumCollectormetrics to useregistry=hs.metrics_collector_registryLaterGaugeGaugeBucketCollectorCPUMetricsGCCountsPyPyGCStatsReactorLastSeenMetric_CollectorJemallocCollectorDynamicCollectorRegistryLruCache@cached_CachedFunctionDescriptoris accounted for in the mypy plugin (scripts-dev/mypy_synapse_plugin.py)Dev notes
Parts of this PR have been split out to other PRs:
metricslistener type in favor ofhttplistener withmetricsresource #18584Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.