-
Notifications
You must be signed in to change notification settings - Fork 455
Description
Expected Behaviour
As a developer, I expect that any exceptions that propagate out of my handler to be logged by default with the typical stack trace, etc. That is standard Lambda behavior.
Current Behaviour
When using the Powertools batch wrapper/dispatcher process_partial_response
any exceptions raised from my handler are not logged as exceptions. That is unless all of the messages in the batch raise an exception.
Code snippet
def failure_handler(self, record, exception: ExceptionInfo) -> FailureResponse:
"""
Keeps track of batch records that failed processing
Parameters
----------
record: Any
record that failed processing
exception: ExceptionInfo
Exception information containing type, value, and traceback (sys.exc_info())
Returns
-------
FailureResponse
"fail", exceptions args, original record
"""
exception_string = f"{exception[0]}:{exception[1]}"
entry = ("fail", exception_string, record)
logger.debug(f"Record processing exception: {exception_string}")
self.exceptions.append(exception)
self.fail_messages.append(record)
return entry
Possible Solution
In BasePartialProcessor.failure_handler the exception is logged with a log.debug
. This is problematic because:
- lacks stack trace information
- Is not typically output to the log by default
- Requires including all DEBUG level logs in order to surface through logging configuration.
A call to log.exception()
, perhaps here, would solve the problem nicely.
Steps to Reproduce
Using BatchProcessor
and process_partial_response
, throw an exception from one of the handler invocations in the batch.
Note that nothing is logged for the exception.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status