0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 07:13:49 +01:00

Fix @trace not wrapping some state methods that return coroutines correctly (#15647)

```
2023-05-21 09:30:09,288 - synapse.logging.opentracing - 940 - ERROR - POST-1 - @trace may not have wrapped StateStorageController.get_state_for_groups correctly! The function is not async but returned a coroutine
```

Tracing instrumentation for these functions originally introduced in https://github.com/matrix-org/synapse/pull/15610
This commit is contained in:
Eric Eastwood 2023-05-23 12:26:25 -05:00 committed by GitHub
parent 7c9b91790c
commit 379eb2d7ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

1
changelog.d/15647.bugfix Normal file
View file

@ -0,0 +1 @@
Instrument `state` and `state_group` storage-related operations to better picture what's happening when tracing.

View file

@ -16,7 +16,6 @@ from typing import (
TYPE_CHECKING, TYPE_CHECKING,
AbstractSet, AbstractSet,
Any, Any,
Awaitable,
Callable, Callable,
Collection, Collection,
Dict, Dict,
@ -175,9 +174,9 @@ class StateStorageController:
@trace @trace
@tag_args @tag_args
def _get_state_groups_from_groups( async def _get_state_groups_from_groups(
self, groups: List[int], state_filter: StateFilter self, groups: List[int], state_filter: StateFilter
) -> Awaitable[Dict[int, StateMap[str]]]: ) -> Dict[int, StateMap[str]]:
"""Returns the state groups for a given set of groups, filtering on """Returns the state groups for a given set of groups, filtering on
types of state events. types of state events.
@ -190,7 +189,9 @@ class StateStorageController:
Dict of state group to state map. Dict of state group to state map.
""" """
return self.stores.state._get_state_groups_from_groups(groups, state_filter) return await self.stores.state._get_state_groups_from_groups(
groups, state_filter
)
@trace @trace
@tag_args @tag_args
@ -349,9 +350,9 @@ class StateStorageController:
@trace @trace
@tag_args @tag_args
def get_state_for_groups( async def get_state_for_groups(
self, groups: Iterable[int], state_filter: Optional[StateFilter] = None self, groups: Iterable[int], state_filter: Optional[StateFilter] = None
) -> Awaitable[Dict[int, MutableStateMap[str]]]: ) -> Dict[int, MutableStateMap[str]]:
"""Gets the state at each of a list of state groups, optionally """Gets the state at each of a list of state groups, optionally
filtering by type/state_key filtering by type/state_key
@ -363,7 +364,7 @@ class StateStorageController:
Returns: Returns:
Dict of state group to state map. Dict of state group to state map.
""" """
return self.stores.state._get_state_for_groups( return await self.stores.state._get_state_for_groups(
groups, state_filter or StateFilter.all() groups, state_filter or StateFilter.all()
) )