mirror of
https://github.com/element-hq/synapse
synced 2024-09-12 09:25:11 +00:00
Instrument FederationStateIdsServlet
This commit is contained in:
parent
597c3f276e
commit
f4ec9d1f74
6 changed files with 19 additions and 2 deletions
|
@ -190,6 +190,8 @@ password_config:
|
|||
tracing:
|
||||
enabled: true
|
||||
sample_rate: 1
|
||||
homeserver_whitelist:
|
||||
- ".*"
|
||||
jaeger_exporter_config:
|
||||
agent_host_name: host.docker.internal
|
||||
agent_port: 6831
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue