Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use unified trace method
Browse files Browse the repository at this point in the history
  • Loading branch information
JorikSchellekens committed Jul 23, 2019
1 parent beea2e3 commit 1801578
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion synapse/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def can_federate(self, event, auth_events):
def get_public_keys(self, invite_event):
return event_auth.get_public_keys(invite_event)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_user_by_req(
self, request, allow_guest=False, rights="access", allow_expired=False
Expand Down
2 changes: 1 addition & 1 deletion synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def on_query_client_keys(self, origin, content):
def on_query_user_devices(self, origin, user_id):
return self.on_query_request("user_devices", user_id)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
@log_function
def on_claim_client_keys(self, origin, content):
Expand Down
14 changes: 7 additions & 7 deletions synapse/handlers/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, hs):
self.state = hs.get_state_handler()
self._auth_handler = hs.get_auth_handler()

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_devices_by_user(self, user_id):
"""
Expand All @@ -70,7 +70,7 @@ def get_devices_by_user(self, user_id):
opentracing.log_kv(device_map)
return devices

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_device(self, user_id, device_id):
""" Retrieve the given device
Expand All @@ -97,7 +97,7 @@ def get_device(self, user_id, device_id):
return device

@measure_func("device.get_user_ids_changed")
@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_user_ids_changed(self, user_id, from_token):
"""Get list of users that have had the devices updated, or have newly
Expand Down Expand Up @@ -287,7 +287,7 @@ def check_device_registered(

raise errors.StoreError(500, "Couldn't generate a device ID.")

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_device(self, user_id, device_id):
""" Delete the given device
Expand Down Expand Up @@ -321,7 +321,7 @@ def delete_device(self, user_id, device_id):

yield self.notify_device_update(user_id, [device_id])

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_all_devices_for_user(self, user_id, except_device_id=None):
"""Delete all of the user's devices
Expand Down Expand Up @@ -399,7 +399,7 @@ def update_device(self, user_id, device_id, content):
else:
raise

@opentracing.trace_deferred
@opentracing.trace
@measure_func("notify_device_update")
@defer.inlineCallbacks
def notify_device_update(self, user_id, device_ids):
Expand Down Expand Up @@ -485,7 +485,7 @@ def __init__(self, hs, device_handler):
iterable=True,
)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def incoming_device_list_update(self, origin, edu_content):
"""Called on incoming device list update from federation. Responsible
Expand Down
10 changes: 5 additions & 5 deletions synapse/handlers/e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, hs):
"client_keys", self.on_federation_query_client_keys
)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def query_devices(self, query_body, timeout):
""" Handle a device key query from a client
Expand Down Expand Up @@ -125,7 +125,7 @@ def query_devices(self, query_body, timeout):
r[user_id] = remote_queries[user_id]

# Now fetch any devices that we don't have in our cache
@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def do_remote_query(destination):
destination_query = remote_queries_not_in_cache[destination]
Expand Down Expand Up @@ -158,7 +158,7 @@ def do_remote_query(destination):

return {"device_keys": results, "failures": failures}

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def query_local_devices(self, query):
"""Get E2E device keys for local users
Expand Down Expand Up @@ -222,7 +222,7 @@ def on_federation_query_client_keys(self, query_body):
res = yield self.query_local_devices(device_keys_query)
return {"device_keys": res}

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def claim_one_time_keys(self, query, timeout):
local_query = []
Expand Down Expand Up @@ -251,7 +251,7 @@ def claim_one_time_keys(self, query, timeout):
key_id: json.loads(json_bytes)
}

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def claim_client_keys(destination):
opentracing.set_tag("destination", destination)
Expand Down
12 changes: 6 additions & 6 deletions synapse/handlers/e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, hs):
# changed.
self._upload_linearizer = Linearizer("upload_room_keys_lock")

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_room_keys(self, user_id, version, room_id=None, session_id=None):
"""Bulk get the E2E room keys for a given backup, optionally filtered to a given
Expand Down Expand Up @@ -89,7 +89,7 @@ def get_room_keys(self, user_id, version, room_id=None, session_id=None):
opentracing.log_kv(results)
return results

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_room_keys(self, user_id, version, room_id=None, session_id=None):
"""Bulk delete the E2E room keys for a given backup, optionally filtered to a given
Expand All @@ -111,7 +111,7 @@ def delete_room_keys(self, user_id, version, room_id=None, session_id=None):
with (yield self._upload_linearizer.queue(user_id)):
yield self.store.delete_e2e_room_keys(user_id, version, room_id, session_id)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def upload_room_keys(self, user_id, version, room_keys):
"""Bulk upload a list of room keys into a given backup version, asserting
Expand Down Expand Up @@ -257,7 +257,7 @@ def _should_replace_room_key(current_room_key, room_key):
return False
return True

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def create_version(self, user_id, version_info):
"""Create a new backup version. This automatically becomes the new
Expand Down Expand Up @@ -316,7 +316,7 @@ def get_version_info(self, user_id, version=None):
raise
return res

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_version(self, user_id, version=None):
"""Deletes a given version of the user's e2e_room_keys backup
Expand All @@ -337,7 +337,7 @@ def delete_version(self, user_id, version=None):
else:
raise

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def update_version(self, user_id, version, version_info):
"""Update the info about a given version of the user's backup
Expand Down
2 changes: 1 addition & 1 deletion synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def deferred_function(*args, **kwargs):

from canonicaljson import json

from twisted.internet import defer,
from twisted.internet import defer

from synapse.config import ConfigError

Expand Down
4 changes: 2 additions & 2 deletions synapse/rest/client/v2_alpha/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, hs):
self.auth = hs.get_auth()
self.e2e_keys_handler = hs.get_e2e_keys_handler()

@opentracing.trace_deferred_using_operation_name("upload_keys")
@opentracing.trace_using_operation_name("upload_keys")
@defer.inlineCallbacks
def on_POST(self, request, device_id):
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(self, hs):
self.auth = hs.get_auth()
self.device_handler = hs.get_device_handler()

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def on_GET(self, request):
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v2_alpha/room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __init__(self, hs):
self.auth = hs.get_auth()
self.e2e_room_keys_handler = hs.get_e2e_room_keys_handler()

@opentracing.trace_deferred_using_operation_name("get_room_keys_version")
@opentracing.trace_using_operation_name("get_room_keys_version")
@defer.inlineCallbacks
def on_GET(self, request, version):
"""
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/v2_alpha/sendtodevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, hs):
self.txns = HttpTransactionCache(hs)
self.device_message_handler = hs.get_device_message_handler()

@opentracing.trace_deferred_using_operation_name("sendToDevice")
@opentracing.trace_using_operation_name("sendToDevice")
def on_PUT(self, request, message_type, txn_id):
opentracing.set_tag("message_type", message_type)
opentracing.set_tag("txn_id", txn_id)
Expand Down
6 changes: 3 additions & 3 deletions synapse/storage/deviceinbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_new_messages_for_device_txn(txn):
"get_new_messages_for_device", get_new_messages_for_device_txn
)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_messages_for_device(self, user_id, device_id, up_to_stream_id):
"""
Expand Down Expand Up @@ -185,7 +185,7 @@ def get_new_messages_for_remote_destination_txn(txn):
get_new_messages_for_remote_destination_txn,
)

@opentracing.trace_deferred
@opentracing.trace
def delete_device_msgs_for_remote(self, destination, up_to_stream_id):
"""Used to delete messages when the remote destination acknowledges
their receipt.
Expand Down Expand Up @@ -236,7 +236,7 @@ def __init__(self, db_conn, hs):
expiry_ms=30 * 60 * 1000,
)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def add_messages_to_device_inbox(
self, local_messages_by_user_then_device, remote_messages_by_destination
Expand Down
4 changes: 2 additions & 2 deletions synapse/storage/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_devices_by_user(self, user_id):

return {d["device_id"]: d for d in devices}

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_devices_by_remote(self, destination, from_stream_id, limit):
"""Get stream of updates to send to remote servers
Expand Down Expand Up @@ -316,7 +316,7 @@ def _mark_as_sent_devices_by_remote_txn(self, txn, destination, stream_id):
def get_device_stream_token(self):
return self._device_list_id_gen.get_current_token()

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_user_devices_from_cache(self, query_list):
"""Get the devices (and keys if any) for remote users from the cache.
Expand Down
10 changes: 5 additions & 5 deletions synapse/storage/e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def set_e2e_room_key(self, user_id, version, room_id, session_id, room_key):
}
)

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_e2e_room_keys(self, user_id, version, room_id=None, session_id=None):
"""Bulk get the E2E room keys for a given backup, optionally filtered to a given
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_e2e_room_keys(self, user_id, version, room_id=None, session_id=None):

return sessions

@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def delete_e2e_room_keys(self, user_id, version, room_id=None, session_id=None):
"""Bulk delete the E2E room keys for a given backup, optionally filtered to a given
Expand Down Expand Up @@ -247,7 +247,7 @@ def _get_e2e_room_keys_version_info_txn(txn):
"get_e2e_room_keys_version_info", _get_e2e_room_keys_version_info_txn
)

@opentracing.trace_deferred
@opentracing.trace
def create_e2e_room_keys_version(self, user_id, info):
"""Atomically creates a new version of this user's e2e_room_keys store
with the given version info.
Expand Down Expand Up @@ -288,7 +288,7 @@ def _create_e2e_room_keys_version_txn(txn):
"create_e2e_room_keys_version_txn", _create_e2e_room_keys_version_txn
)

@opentracing.trace_deferred
@opentracing.trace
def update_e2e_room_keys_version(self, user_id, version, info):
"""Update a given backup version
Expand All @@ -305,7 +305,7 @@ def update_e2e_room_keys_version(self, user_id, version, info):
desc="update_e2e_room_keys_version",
)

@opentracing.trace_deferred
@opentracing.trace
def delete_e2e_room_keys_version(self, user_id, version=None):
"""Delete a given backup version of the user's room keys.
Doesn't delete their actual key data.
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/end_to_end_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class EndToEndKeyWorkerStore(SQLBaseStore):
@opentracing.trace_deferred
@opentracing.trace
@defer.inlineCallbacks
def get_e2e_device_keys(
self, query_list, include_all_devices=False, include_deleted_devices=False
Expand Down

0 comments on commit 1801578

Please sign in to comment.