summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-08-04 01:24:58 -0500
committerEric Eastwood <erice@element.io>2022-08-04 01:24:58 -0500
commita7eabb78a2b22ca4ce5fd5838b77a84530d109f4 (patch)
treeeb253b9037b0caab8f930c260f282f3bbeeb8096 /synapse
parentAllow @trace and @tag_args to be used together (diff)
downloadsynapse-a7eabb78a2b22ca4ce5fd5838b77a84530d109f4.tar.xz
Trace more
Diffstat (limited to 'synapse')
-rw-r--r--synapse/federation/federation_client.py3
-rw-r--r--synapse/handlers/federation.py5
-rw-r--r--synapse/logging/tracing.py4
-rw-r--r--synapse/storage/controllers/state.py1
-rw-r--r--synapse/storage/databases/main/event_federation.py3
5 files changed, 11 insertions, 5 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py
index dfd0bc414e..76b39408ec 100644
--- a/synapse/federation/federation_client.py
+++ b/synapse/federation/federation_client.py
@@ -61,7 +61,7 @@ from synapse.federation.federation_base import (
 )
 from synapse.federation.transport.client import SendJoinResponse
 from synapse.http.types import QueryParams
-from synapse.logging.tracing import trace
+from synapse.logging.tracing import trace, tag_args
 from synapse.types import JsonDict, UserID, get_domain_from_id
 from synapse.util.async_helpers import concurrently_execute
 from synapse.util.caches.expiringcache import ExpiringCache
@@ -235,6 +235,7 @@ class FederationClient(FederationBase):
         )
 
     @trace
+    @tag_args
     async def backfill(
         self, dest: str, room_id: str, limit: int, extremities: Collection[str]
     ) -> Optional[List[EventBase]]:
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 0aa4878f5b..0cd9597dc5 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -59,7 +59,7 @@ from synapse.events.validator import EventValidator
 from synapse.federation.federation_client import InvalidResponseError
 from synapse.http.servlet import assert_params_in_dict
 from synapse.logging.context import nested_logging_context
-from synapse.logging.tracing import trace
+from synapse.logging.tracing import trace, set_attribute
 from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.module_api import NOT_SPAM
 from synapse.replication.http.federation import (
@@ -319,7 +319,8 @@ class FederationHandler:
         # attempting to paginate before backfill reached the visible history.
 
         extremities_to_request: List[str] = []
-        for bp in sorted_backfill_points:
+        for i, bp in enumerate(sorted_backfill_points):
+            set_attribute("backfill_point" + str(i), str(bp))
             if len(extremities_to_request) >= 5:
                 break
 
diff --git a/synapse/logging/tracing.py b/synapse/logging/tracing.py
index 552f5f8504..2f4555cc2e 100644
--- a/synapse/logging/tracing.py
+++ b/synapse/logging/tracing.py
@@ -917,8 +917,8 @@ def tag_args(func: Callable[P, R]) -> Callable[P, R]:
     @contextlib.contextmanager
     def _wrapping_logic(func: Callable[P, R], *args: P.args, **kwargs: P.kwargs):
         argspec = inspect.getfullargspec(func)
-        for i, arg in enumerate(argspec.args[1:]):
-            set_attribute("ARG_" + arg, str(args[i + 1]))  # type: ignore[index]
+        for i, arg in enumerate(args[1:]):
+            set_attribute("ARG_" + argspec.args[i + 1], str(arg))  # type: ignore[index]
         set_attribute("args", str(args[len(argspec.args) :]))  # type: ignore[index]
         set_attribute("kwargs", str(kwargs))
         yield
diff --git a/synapse/storage/controllers/state.py b/synapse/storage/controllers/state.py
index 7b2084664c..7fb12f4df6 100644
--- a/synapse/storage/controllers/state.py
+++ b/synapse/storage/controllers/state.py
@@ -473,6 +473,7 @@ class StateStorageController:
             prev_stream_id, max_stream_id
         )
 
+    @trace
     async def get_current_state(
         self, room_id: str, state_filter: Optional[StateFilter] = None
     ) -> StateMap[EventBase]:
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index 22e72a31de..3fcb2069df 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -770,6 +770,7 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
             room_id,
         )
 
+    @trace
     async def get_insertion_event_backward_extremities_in_room(
         self, room_id: str
     ) -> List[Tuple[str, int]]:
@@ -1342,6 +1343,8 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
         event_results.reverse()
         return event_results
 
+    @trace
+    @tag_args
     async def get_successor_events(self, event_id: str) -> List[str]:
         """Fetch all events that have the given event as a prev event