def _patch_class()

in aws_xray_sdk/core/patcher.py [0:0]


def _patch_class(module, cls):
    for member_name, member in inspect.getmembers(cls, inspect.isclass):
        if member.__module__ == module.__name__:
            # Only patch classes of the module, ignore imports
            _patch_class(module, member)

    for member_name, member in inspect.getmembers(cls, inspect.ismethod):
        if member.__module__ == module.__name__:
            # Only patch methods of the class defined in the module, ignore other modules
            if is_classmethod(member):
                # classmethods are internally generated through descriptors. The classmethod
                # decorator must be the last applied, so we cannot apply another one on top
                log.warning('Cannot automatically patch classmethod %s.%s, '
                            'please apply decorator manually', cls.__name__, member_name)
            else:
                _patch_func(cls, member_name, member)

    for member_name, member in inspect.getmembers(cls, inspect.isfunction):
        if member.__module__ == module.__name__:
            # Only patch static methods of the class defined in the module, ignore other modules
            if is_instance_method(cls, member_name, member):
                _patch_func(cls, member_name, member)
            else:
                _patch_func(cls, member_name, member, modifier=staticmethod)