mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Instrument FederationStateIdsServlet
- /state_ids
(#13499)
Instrument FederationStateIdsServlet - `/state_ids` so it's easier to follow what's going on in Jaeger when viewing a trace.
This commit is contained in:
parent
19e5d44886
commit
344a2f767c
1
changelog.d/13499.misc
Normal file
1
changelog.d/13499.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Instrument `FederationStateIdsServlet` (`/state_ids`) for understandable traces in Jaeger.
|
@ -61,7 +61,12 @@ from synapse.logging.context import (
|
|||||||
nested_logging_context,
|
nested_logging_context,
|
||||||
run_in_background,
|
run_in_background,
|
||||||
)
|
)
|
||||||
from synapse.logging.opentracing import log_kv, start_active_span_from_edu, trace
|
from synapse.logging.opentracing import (
|
||||||
|
log_kv,
|
||||||
|
start_active_span_from_edu,
|
||||||
|
tag_args,
|
||||||
|
trace,
|
||||||
|
)
|
||||||
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
||||||
from synapse.replication.http.federation import (
|
from synapse.replication.http.federation import (
|
||||||
ReplicationFederationSendEduRestServlet,
|
ReplicationFederationSendEduRestServlet,
|
||||||
@ -547,6 +552,8 @@ class FederationServer(FederationBase):
|
|||||||
|
|
||||||
return 200, resp
|
return 200, resp
|
||||||
|
|
||||||
|
@trace
|
||||||
|
@tag_args
|
||||||
async def on_state_ids_request(
|
async def on_state_ids_request(
|
||||||
self, origin: str, room_id: str, event_id: str
|
self, origin: str, room_id: str, event_id: str
|
||||||
) -> Tuple[int, JsonDict]:
|
) -> Tuple[int, JsonDict]:
|
||||||
@ -569,6 +576,8 @@ class FederationServer(FederationBase):
|
|||||||
|
|
||||||
return 200, resp
|
return 200, resp
|
||||||
|
|
||||||
|
@trace
|
||||||
|
@tag_args
|
||||||
async def _on_state_ids_request_compute(
|
async def _on_state_ids_request_compute(
|
||||||
self, room_id: str, event_id: str
|
self, room_id: str, event_id: str
|
||||||
) -> JsonDict:
|
) -> JsonDict:
|
||||||
|
@ -59,7 +59,7 @@ from synapse.events.validator import EventValidator
|
|||||||
from synapse.federation.federation_client import InvalidResponseError
|
from synapse.federation.federation_client import InvalidResponseError
|
||||||
from synapse.http.servlet import assert_params_in_dict
|
from synapse.http.servlet import assert_params_in_dict
|
||||||
from synapse.logging.context import nested_logging_context
|
from synapse.logging.context import nested_logging_context
|
||||||
from synapse.logging.opentracing import trace
|
from synapse.logging.opentracing import tag_args, trace
|
||||||
from synapse.metrics.background_process_metrics import run_as_background_process
|
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||||
from synapse.module_api import NOT_SPAM
|
from synapse.module_api import NOT_SPAM
|
||||||
from synapse.replication.http.federation import (
|
from synapse.replication.http.federation import (
|
||||||
@ -1081,6 +1081,8 @@ class FederationHandler:
|
|||||||
|
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
@trace
|
||||||
|
@tag_args
|
||||||
async def get_state_ids_for_pdu(self, room_id: str, event_id: str) -> List[str]:
|
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."""
|
"""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)
|
event = await self.store.get_event(event_id, check_room_id=room_id)
|
||||||
|
@ -33,6 +33,7 @@ from synapse.api.constants import MAX_DEPTH, EventTypes
|
|||||||
from synapse.api.errors import StoreError
|
from synapse.api.errors import StoreError
|
||||||
from synapse.api.room_versions import EventFormatVersions, RoomVersion
|
from synapse.api.room_versions import EventFormatVersions, RoomVersion
|
||||||
from synapse.events import EventBase, make_event_from_dict
|
from synapse.events import EventBase, make_event_from_dict
|
||||||
|
from synapse.logging.opentracing import tag_args, trace
|
||||||
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
||||||
from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause
|
from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause
|
||||||
from synapse.storage.database import (
|
from synapse.storage.database import (
|
||||||
@ -126,6 +127,8 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
|
|||||||
)
|
)
|
||||||
return await self.get_events_as_list(event_ids)
|
return await self.get_events_as_list(event_ids)
|
||||||
|
|
||||||
|
@trace
|
||||||
|
@tag_args
|
||||||
async def get_auth_chain_ids(
|
async def get_auth_chain_ids(
|
||||||
self,
|
self,
|
||||||
room_id: str,
|
room_id: str,
|
||||||
|
@ -27,6 +27,7 @@ from synapse.logging.context import (
|
|||||||
make_deferred_yieldable,
|
make_deferred_yieldable,
|
||||||
run_in_background,
|
run_in_background,
|
||||||
)
|
)
|
||||||
|
from synapse.logging.opentracing import start_active_span
|
||||||
from synapse.util import Clock
|
from synapse.util import Clock
|
||||||
|
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
@ -176,8 +177,11 @@ class _PerHostRatelimiter:
|
|||||||
# Ensure that we've properly cleaned up.
|
# Ensure that we've properly cleaned up.
|
||||||
self.sleeping_requests.discard(request_id)
|
self.sleeping_requests.discard(request_id)
|
||||||
self.ready_request_queue.pop(request_id, None)
|
self.ready_request_queue.pop(request_id, None)
|
||||||
|
wait_span_scope.__exit__(None, None, None)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
wait_span_scope = start_active_span("ratelimit wait")
|
||||||
|
wait_span_scope.__enter__()
|
||||||
ret_defer.addCallbacks(on_start, on_err)
|
ret_defer.addCallbacks(on_start, on_err)
|
||||||
ret_defer.addBoth(on_both)
|
ret_defer.addBoth(on_both)
|
||||||
return make_deferred_yieldable(ret_defer)
|
return make_deferred_yieldable(ret_defer)
|
||||||
|
Loading…
Reference in New Issue
Block a user