mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 19:08:43 -05:00
Add type annotations to synapse.metrics (#10847)
This commit is contained in:
parent
d993c3bb1e
commit
84fac0f814
12 changed files with 174 additions and 86 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue