From 84c8f1cd9c9fc84fe543365b385d841346209ba0 Mon Sep 17 00:00:00 2001 From: Steven Woods Date: Sat, 6 Apr 2024 12:22:33 +0100 Subject: [PATCH] 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 --- python3/packages/observer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python3/packages/observer.py b/python3/packages/observer.py index 3419c89cd36..076fa986a9a 100644 --- a/python3/packages/observer.py +++ b/python3/packages/observer.py @@ -28,6 +28,7 @@ import runpy import sys import traceback +import types from datetime import datetime, timezone from logging.handlers import SysLogHandler from typing import List, Sequence @@ -288,7 +289,9 @@ def instrument_function(wrapped, _, args, kwargs): # class or classmethod aspan.set_attribute("xs.span.args.str", str(args)) aspan.set_attribute("xs.span.kwargs.str", str(kwargs)) - else: + elif isinstance(wrapped, wrapt.PartialCallableObjectProxy): + pass + elif isinstance(wrapped, (types.FunctionType, types.MethodType)): # function, staticmethod or instancemethod bound_args = inspect.signature(wrapped).bind(*args, **kwargs) bound_args.apply_defaults()