diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py
index 86baf397fb..2046b8e276 100644
--- a/synapse/storage/databases/main/events.py
+++ b/synapse/storage/databases/main/events.py
@@ -16,6 +16,7 @@
import itertools
import logging
from collections import OrderedDict, namedtuple
+from synapse.logging.opentracing import start_active_span
from typing import (
TYPE_CHECKING,
Any,
@@ -382,7 +383,8 @@ class PersistEventsStore:
# Insert into event_to_state_groups.
self._store_event_state_mappings_txn(txn, events_and_contexts)
- self._persist_event_auth_chain_txn(txn, [e for e, _ in events_and_contexts])
+ with start_active_span("_persist_event_auth_chain_txn"):
+ self._persist_event_auth_chain_txn(txn, [e for e, _ in events_and_contexts])
# _store_rejected_events_txn filters out any events which were
# rejected, and returns the filtered list.
@@ -393,12 +395,13 @@ class PersistEventsStore:
# From this point onwards the events are only ones that weren't
# rejected.
- self._update_metadata_tables_txn(
- txn,
- events_and_contexts=events_and_contexts,
- all_events_and_contexts=all_events_and_contexts,
- backfilled=backfilled,
- )
+ with start_active_span("_update_metadata_tables_txn"):
+ self._update_metadata_tables_txn(
+ txn,
+ events_and_contexts=events_and_contexts,
+ all_events_and_contexts=all_events_and_contexts,
+ backfilled=backfilled,
+ )
# We call this last as it assumes we've inserted the events into
# room_memberships, where applicable.
diff --git a/synapse/storage/persist_events.py b/synapse/storage/persist_events.py
index 0e8270746d..a19f75061b 100644
--- a/synapse/storage/persist_events.py
+++ b/synapse/storage/persist_events.py
@@ -445,7 +445,9 @@ class EventsPersistenceStorage:
potentially_left_users: Set[str] = set()
if not backfilled:
- with Measure(self._clock, "_calculate_state_and_extrem"):
+ with Measure(
+ self._clock, "_calculate_state_and_extrem"
+ ), opentracing.start_active_span("_calculate_state_and_extrem"):
# Work out the new "current state" for each room.
# We do this by working out what the new extremities are and then
# calculating the state from that.
|