-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Some of the Lambda code is catching exceptions and then not re-raising those exceptions. When the exceptions are not re-raised, then the Lambda execution will show as successful, not an error.
And if the Lambda executions are not recognizing an error, then we cannot rely on Lambda Cloudwatch metrics for errors to monitor failures of these Lambdas effectively.
A lot of the try/except blocks seem to be there solely for the purpose of logging the exception. While logging an exception is helpful, it's preferable if the exception just causes the Lambda fail, which will result in the exception appearing in the Lambda logs by default.
To do
- Update code to avoid catching exceptions just to log the error. Instead, let the exception go uncaught
- For example:
aws_opensearch_preprocess_lambdas/lambda_functions/transform_cloudwatch_lambda.py
Line 120 in 161a01e
logger.error(f"Failed to push final batch to S3: {str(e)}")
- For example:
- Make sure any exceptions that must be caught are re-raised where appropriate
- Update tests to reflect new exception handling approach