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

Opentrace device lists #5853

Merged
merged 36 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bdf8e51
Newsfile
erikjohnston Aug 14, 2019
8629a68
Fixup changelog and remove debug logging
erikjohnston Aug 16, 2019
9043403
Stylish imports
JorikSchellekens Aug 14, 2019
98afb14
Trace devices
JorikSchellekens Jun 28, 2019
b0d2e26
Trace device messages.
JorikSchellekens Jun 28, 2019
0b3d088
Update to new access pattern
JorikSchellekens Jul 2, 2019
34f6214
How did that half of the statement get deleted?
JorikSchellekens Jul 3, 2019
e358f00
These functions were not deferreds!
JorikSchellekens Jul 4, 2019
6a2ac72
The great logging/ migration
JorikSchellekens Jul 4, 2019
09e40a0
Some tracing
JorikSchellekens Jul 8, 2019
78a0123
Nicer tracing
JorikSchellekens Jul 11, 2019
b9db310
A little extra device_list tracing
JorikSchellekens Jul 15, 2019
6068b69
Use better decorator names.
JorikSchellekens Jul 17, 2019
e5155ee
Use unified trace method
JorikSchellekens Jul 22, 2019
c35f9d9
Refactor return value so we don't create identical lists each time.
JorikSchellekens Aug 5, 2019
303fcce
String concatenation without the '+'
JorikSchellekens Aug 5, 2019
d7d8492
Use underscores.
JorikSchellekens Aug 5, 2019
68d4c94
isort
JorikSchellekens Aug 14, 2019
8869422
Bad return type
JorikSchellekens Aug 14, 2019
08787f4
newsfile
JorikSchellekens Aug 14, 2019
42c2acd
Use the import style.
JorikSchellekens Aug 14, 2019
547f125
Remove astray indent
JorikSchellekens Aug 15, 2019
ff86fa6
Import style
JorikSchellekens Aug 16, 2019
395ee6a
Missing import
JorikSchellekens Aug 16, 2019
83a011f
Unused import
JorikSchellekens Aug 16, 2019
8769aa3
Feature and simplification
JorikSchellekens Aug 20, 2019
656e3b7
Underscores
JorikSchellekens Aug 20, 2019
fb87863
Allow the passing of operation_name to trace
JorikSchellekens Aug 22, 2019
1f5b9b0
Old import
JorikSchellekens Aug 23, 2019
47f8a59
Remove unused import
JorikSchellekens Aug 27, 2019
071b04d
Use the the keyword in the trace method
JorikSchellekens Aug 27, 2019
4d68ac0
Cleanup trace method
JorikSchellekens Sep 2, 2019
bce66ae
Merge branch 'develop' into joriks/opentraicng_devices
JorikSchellekens Sep 2, 2019
1c86773
Merge was not black
JorikSchellekens Sep 2, 2019
fa17018
opname not operation_name
JorikSchellekens Sep 3, 2019
1b5c891
Remove comment
JorikSchellekens Sep 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def interesting_function(*args, **kwargs):

from synapse.logging.opentracing import trace

@trace(operation_name="A *much* better operation name")
@trace(operation_name="a_better_operation_name")
JorikSchellekens marked this conversation as resolved.
Show resolved Hide resolved
def interesting_badly_named_function(*args, **kwargs):
# Does all kinds of cool and expected things
return something_usual_and_useful
Expand Down Expand Up @@ -641,19 +641,22 @@ def extract_text_map(carrier):
# Tracing decorators


def trace(func=None, operation_name=None):
def trace(func=None, opname=None):
"""
Decorator to trace a function.
Sets the operation name to that of the function's.
Sets the operation name to that of the function's or that given
as operation_name. See the module's doc string for usage
examples.
"""

if func and not operation_name:
operation_name = func.__name__

def decorator(func):
if opentracing is None:
return func

# Doing this weird assignment thing to get around local variable
# referenced before assignment 'bug' raised by checkstyle
JorikSchellekens marked this conversation as resolved.
Show resolved Hide resolved
operation_name = opname if opname else func.__name__

@wraps(func)
def _trace_inner(self, *args, **kwargs):
if opentracing is None:
Expand Down
2 changes: 1 addition & 1 deletion 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()

@trace(operation_name="upload_keys")
@trace(opname="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
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()

@trace(operation_name="sendToDevice")
@trace(opname="sendToDevice")
def on_PUT(self, request, message_type, txn_id):
set_tag("message_type", message_type)
set_tag("txn_id", txn_id)
Expand Down
2 changes: 1 addition & 1 deletion synapse/storage/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def get_user_devices_from_cache(self, query_list):
set_tag("in_cache", results)
set_tag("not_in_cache", user_ids_not_in_cache)

return (user_ids_not_in_cache, results)
return user_ids_not_in_cache, results

@cachedInlineCallbacks(num_args=2, tree=True)
def _get_cached_user_device(self, user_id, device_id):
Expand Down