def sentry_monitor(error_stream=None, **kwargs):
    """Sentry monitoring for AWS Lambda handler."""
    def decorator(func):
        """A decorator that adds Sentry monitoring to a Lambda handler."""
        def wrapper(event, context):
            """Wrap the target function."""
            client = _setup_sentry_client(context)
            try:
                return func(event, context)
            except (ProcessingError, OutOfOrderError) as err:
                # A controlled exception from the Kinesis processor
                _handle_processing_error(err, error_stream, client)
            except Exception as err:
                # Raise the exception and block the stream processor
                if client:
                    client.captureException()
                raise
        return wrapper

    return decorator
Sentry monitoring for AWS Lambda handler.