code: def mock_xray_client(f):
      
      @wraps(f)
      def _wrapped(*args, **kwargs):
          print("Starting X-Ray Patch")
  
          old_xray_context_var = os.environ.get('AWS_XRAY_CONTEXT_MISSING')
          os.environ['AWS_XRAY_CONTEXT_MISSING'] = 'LOG_ERROR'
          old_xray_context = aws_xray_sdk.core.xray_recorder._context
          old_xray_emitter = aws_xray_sdk.core.xray_recorder._emitter
          aws_xray_sdk.core.xray_recorder._context = AWSContext()
          aws_xray_sdk.core.xray_recorder._emitter = MockEmitter()
  
          try:
              return f(*args, **kwargs)
          finally:
  
              if old_xray_context_var is None:
                  del os.environ['AWS_XRAY_CONTEXT_MISSING']
              else:
                  os.environ['AWS_XRAY_CONTEXT_MISSING'] = old_xray_context_var
  
              aws_xray_sdk.core.xray_recorder._emitter = old_xray_emitter
              aws_xray_sdk.core.xray_recorder._context = old_xray_context
  
      return _wrapped
docs: Mocks the X-Ray sdk by pwning its evil singleton with our methods
  
      The X-Ray SDK has normally been imported and `patched()` called long before we start mocking.
      This means the Context() will be very unhappy if an env var isnt present, so we set that, save
      the old context, then supply our new context.
      We also patch the Emitter by subclassing the UDPEmitter class replacing its methods and pushing
      that itno the recorder instance.