Skip to content

Commit 3931c74

Browse files
committed
CA-391381: Avoid errors for Partial Callables in observer.py
This unblocks the Storage: BST to use distributed tracing as the sr_uuid parameter is sometimes not given. Signed-off-by: Steven Woods <steven.woods@citrix.com>
1 parent 7666f7e commit 3931c74

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python3/packages/observer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import runpy
2929
import sys
3030
import traceback
31+
import types
3132
from datetime import datetime, timezone
3233
from logging.handlers import SysLogHandler
3334
from typing import List, Sequence
@@ -288,12 +289,13 @@ def instrument_function(wrapped, _, args, kwargs):
288289
# class or classmethod
289290
aspan.set_attribute("xs.span.args.str", str(args))
290291
aspan.set_attribute("xs.span.kwargs.str", str(kwargs))
291-
else:
292-
# function, staticmethod or instancemethod
292+
elif type(wrapped)==types.FunctionType or type(wrapped)==types.MethodType:
293293
bound_args = inspect.signature(wrapped).bind(*args, **kwargs)
294294
bound_args.apply_defaults()
295295
for k, v in bound_args.arguments.items():
296296
aspan.set_attribute(f"xs.span.arg.{k}", str(v))
297+
else: #eg. class 'PartialCallableObjectProxy'
298+
pass
297299

298300
# must be inside "aspan" to produce nested trace
299301
result = wrapped(*args, **kwargs)

0 commit comments

Comments
 (0)