summary refs log tree commit diff
path: root/synapse/metrics
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-02-02 16:51:00 +0000
committerGitHub <noreply@github.com>2022-02-02 16:51:00 +0000
commit41818cda1fcb086fc41cab7b60da46954ec1dd4a (patch)
tree3539b72f479b80b99976eaf8c56d07875b534a46 /synapse/metrics
parentFix losing incoming EDUs if debug logging enabled (#11890) (diff)
downloadsynapse-41818cda1fcb086fc41cab7b60da46954ec1dd4a.tar.xz
Fix type errors introduced by new annotations in the Prometheus Client library. (#11832)
Co-authored-by: David Robertson <davidr@element.io>
Diffstat (limited to 'synapse/metrics')
-rw-r--r--synapse/metrics/__init__.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index 9e6c1b2f3b..cca084c18c 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -30,6 +30,7 @@ from typing import (
     Type,
     TypeVar,
     Union,
+    cast,
 )
 
 import attr
@@ -60,7 +61,7 @@ all_gauges: "Dict[str, Union[LaterGauge, InFlightGauge]]" = {}
 HAVE_PROC_SELF_STAT = os.path.exists("/proc/self/stat")
 
 
-class RegistryProxy:
+class _RegistryProxy:
     @staticmethod
     def collect() -> Iterable[Metric]:
         for metric in REGISTRY.collect():
@@ -68,6 +69,13 @@ class RegistryProxy:
                 yield metric
 
 
+# A little bit nasty, but collect() above is static so a Protocol doesn't work.
+# _RegistryProxy matches the signature of a CollectorRegistry instance enough
+# for it to be usable in the contexts in which we use it.
+# TODO Do something nicer about this.
+RegistryProxy = cast(CollectorRegistry, _RegistryProxy)
+
+
 @attr.s(slots=True, hash=True, auto_attribs=True)
 class LaterGauge: