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

Don't assume there is a 'self' arg in @trace decorator #5991

Merged
merged 3 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions changelog.d/5991.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invalid references to None while opentracing if the log context slips.
10 changes: 5 additions & 5 deletions synapse/logging/opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,15 @@ def decorator(func):
_opname = opname if opname else func.__name__

@wraps(func)
def _trace_inner(self, *args, **kwargs):
def _trace_inner(*args, **kwargs):
if opentracing is None:
return func(self, *args, **kwargs)
return func(*args, **kwargs)

scope = start_active_span(_opname)
scope.__enter__()

try:
result = func(self, *args, **kwargs)
result = func(*args, **kwargs)
if isinstance(result, defer.Deferred):

def call_back(result):
Expand Down Expand Up @@ -750,13 +750,13 @@ def tag_args(func):
return func

@wraps(func)
def _tag_args_inner(self, *args, **kwargs):
def _tag_args_inner(*args, **kwargs):
argspec = inspect.getargspec(func)
for i, arg in enumerate(argspec.args[1:]):
set_tag("ARG_" + arg, args[i])
set_tag("args", args[len(argspec.args) :])
set_tag("kwargs", kwargs)
return func(self, *args, **kwargs)
return func(*args, **kwargs)

return _tag_args_inner

Expand Down