Add type annotations to synapse.metrics (#10847)

This commit is contained in:
Sean Quah 2021-11-17 19:07:02 +00:00 committed by GitHub
parent d993c3bb1e
commit 84fac0f814
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 174 additions and 86 deletions

View file

@ -159,7 +159,7 @@ class ExpiringCache(Generic[KT, VT]):
self[key] = value
return value
def _prune_cache(self) -> None:
async def _prune_cache(self) -> None:
if not self._expiry_ms:
# zero expiry time means don't expire. This should never get called
# since we have this check in start too.

View file

@ -56,14 +56,6 @@ block_db_sched_duration = Counter(
"synapse_util_metrics_block_db_sched_duration_seconds", "", ["block_name"]
)
# Tracks the number of blocks currently active
in_flight = InFlightGauge(
"synapse_util_metrics_block_in_flight",
"",
labels=["block_name"],
sub_metrics=["real_time_max", "real_time_sum"],
)
# This is dynamically created in InFlightGauge.__init__.
class _InFlightMetric(Protocol):
@ -71,6 +63,15 @@ class _InFlightMetric(Protocol):
real_time_sum: float
# Tracks the number of blocks currently active
in_flight: InFlightGauge[_InFlightMetric] = InFlightGauge(
"synapse_util_metrics_block_in_flight",
"",
labels=["block_name"],
sub_metrics=["real_time_max", "real_time_sum"],
)
T = TypeVar("T", bound=Callable[..., Any])