summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-08-10 18:13:16 -0500
committerEric Eastwood <erice@element.io>2022-08-10 18:13:16 -0500
commitf4ec9d1f74a8b1e759a9a58715e0bdbffd65020e (patch)
treec4d39d6f3b5f3492db4ae3ce5fed7275342a95f1 /synapse
parentTrace some results (diff)
downloadsynapse-f4ec9d1f74a8b1e759a9a58715e0bdbffd65020e.tar.xz
Instrument FederationStateIdsServlet
Diffstat (limited to 'synapse')
-rw-r--r--synapse/federation/federation_server.py6
-rw-r--r--synapse/handlers/federation.py4
-rw-r--r--synapse/rest/client/room.py2
-rw-r--r--synapse/storage/databases/main/event_federation.py2
-rw-r--r--synapse/util/ratelimitutils.py5
5 files changed, 17 insertions, 2 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index c5b3b3cedf..716cbc5cef 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -61,7 +61,7 @@ from synapse.logging.context import (
     nested_logging_context,
     run_in_background,
 )
-from synapse.logging.tracing import log_kv, start_active_span_from_edu, trace
+from synapse.logging.tracing import log_kv, start_active_span_from_edu, trace, tag_args
 from synapse.metrics.background_process_metrics import wrap_as_background_process
 from synapse.replication.http.federation import (
     ReplicationFederationSendEduRestServlet,
@@ -547,6 +547,8 @@ class FederationServer(FederationBase):
 
         return 200, resp
 
+    @trace
+    @tag_args
     async def on_state_ids_request(
         self, origin: str, room_id: str, event_id: str
     ) -> Tuple[int, JsonDict]:
@@ -569,6 +571,8 @@ class FederationServer(FederationBase):
 
         return 200, resp
 
+    @trace
+    @tag_args
     async def _on_state_ids_request_compute(
         self, room_id: str, event_id: str
     ) -> JsonDict:
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 0851ea4bc7..45d56402ec 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 SynapseTags, set_attribute, trace
+from synapse.logging.tracing import SynapseTags, set_attribute, trace, tag_args
 from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.module_api import NOT_SPAM
 from synapse.replication.http.federation import (
@@ -1085,6 +1085,8 @@ class FederationHandler:
 
         return event
 
+    @trace
+    @tag_args
     async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:
         """Returns the state at the event. i.e. not including said event."""
         event = await self.store.get_event(event_id, check_room_id=room_id)
diff --git a/synapse/rest/client/room.py b/synapse/rest/client/room.py
index 3880846e9a..94fc6bba84 100644
--- a/synapse/rest/client/room.py
+++ b/synapse/rest/client/room.py
@@ -563,6 +563,7 @@ class RoomMessageListRestServlet(RestServlet):
     async def on_GET(
         self, request: SynapseRequest, room_id: str
     ) -> Tuple[int, JsonDict]:
+        logger.info("RoomMessageListRestServlet afwefaewfewfew")
         requester = await self.auth.get_user_by_req(request, allow_guest=True)
         pagination_config = await PaginationConfig.from_request(
             self.store, request, default_limit=10
@@ -592,6 +593,7 @@ class RoomMessageListRestServlet(RestServlet):
             as_client_event=as_client_event,
             event_filter=event_filter,
         )
+        logger.info("RoomMessageListRestServlet afwefaewfewfew got msgs")
 
         return 200, msgs
 
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index 178536b10f..41b015dba1 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -127,6 +127,8 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
         )
         return await self.get_events_as_list(event_ids)
 
+    @trace
+    @tag_args
     async def get_auth_chain_ids(
         self,
         room_id: str,
diff --git a/synapse/util/ratelimitutils.py b/synapse/util/ratelimitutils.py
index 6394cc39ac..b04e440f58 100644
--- a/synapse/util/ratelimitutils.py
+++ b/synapse/util/ratelimitutils.py
@@ -21,6 +21,7 @@ from typing import Any, DefaultDict, Iterator, List, Set
 from twisted.internet import defer
 
 from synapse.api.errors import LimitExceededError
+from synapse.logging.tracing import start_active_span
 from synapse.config.ratelimiting import FederationRatelimitSettings
 from synapse.logging.context import (
     PreserveLoggingContext,
@@ -110,6 +111,9 @@ class _PerHostRatelimiter:
     def _on_enter(self, request_id: object) -> "defer.Deferred[None]":
         time_now = self.clock.time_msec()
 
+        wait_span_cm = start_active_span("ratelimit wait")
+        wait_span_cm.__enter__()
+
         # remove any entries from request_times which aren't within the window
         self.request_times[:] = [
             r for r in self.request_times if time_now - r < self.window_size
@@ -162,6 +166,7 @@ class _PerHostRatelimiter:
 
         def on_start(r: object) -> object:
             logger.debug("Ratelimit [%s]: Processing req", id(request_id))
+            wait_span_cm.__exit__(None, None, None)
             self.current_processing.add(request_id)
             return r