mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 05:43:52 +01:00
Merge pull request #5991 from matrix-org/erikj/fix_tracing_funcs
Don't assume there is a 'self' arg in @trace decorator
This commit is contained in:
commit
146af7b47f
2 changed files with 6 additions and 5 deletions
1
changelog.d/5991.bugfix
Normal file
1
changelog.d/5991.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix invalid references to None while opentracing if the log context slips.
|
|
@ -702,15 +702,15 @@ def trace(func=None, opname=None):
|
||||||
_opname = opname if opname else func.__name__
|
_opname = opname if opname else func.__name__
|
||||||
|
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def _trace_inner(self, *args, **kwargs):
|
def _trace_inner(*args, **kwargs):
|
||||||
if opentracing is None:
|
if opentracing is None:
|
||||||
return func(self, *args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
scope = start_active_span(_opname)
|
scope = start_active_span(_opname)
|
||||||
scope.__enter__()
|
scope.__enter__()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = func(self, *args, **kwargs)
|
result = func(*args, **kwargs)
|
||||||
if isinstance(result, defer.Deferred):
|
if isinstance(result, defer.Deferred):
|
||||||
|
|
||||||
def call_back(result):
|
def call_back(result):
|
||||||
|
@ -750,13 +750,13 @@ def tag_args(func):
|
||||||
return func
|
return func
|
||||||
|
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def _tag_args_inner(self, *args, **kwargs):
|
def _tag_args_inner(*args, **kwargs):
|
||||||
argspec = inspect.getargspec(func)
|
argspec = inspect.getargspec(func)
|
||||||
for i, arg in enumerate(argspec.args[1:]):
|
for i, arg in enumerate(argspec.args[1:]):
|
||||||
set_tag("ARG_" + arg, args[i])
|
set_tag("ARG_" + arg, args[i])
|
||||||
set_tag("args", args[len(argspec.args) :])
|
set_tag("args", args[len(argspec.args) :])
|
||||||
set_tag("kwargs", kwargs)
|
set_tag("kwargs", kwargs)
|
||||||
return func(self, *args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
return _tag_args_inner
|
return _tag_args_inner
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue