in handlers/aws/utils.py [0:0]
def wrapper(lambda_event: dict[str, Any], lambda_context: context_.Context) -> str:
apm_client: Client = get_apm_client()
try:
return func(lambda_event, lambda_context)
# NOTE: for all these cases we want the exception to bubble up to Lambda platform and let the defined retry
# mechanism take action. These are non-transient unrecoverable error from this code point of view.
except (
ConfigFileException,
InputConfigException,
OutputConfigException,
TriggerTypeException,
ReplayHandlerException,
) as e:
if apm_client:
apm_client.capture_exception() # type: ignore
shared_logger.exception("exception raised", exc_info=e)
raise e
# NOTE: any generic exception is logged and suppressed to prevent the entire Lambda function to fail.
# As Lambda can process multiple events, when within a Lambda execution only some event produce an Exception
# it should not prevent all other events to be ingested.
except Exception as e:
if apm_client:
apm_client.capture_exception() # type: ignore
shared_logger.exception(
"exception raised",
exc_info=e,
extra={
"summary": summarize_lambda_event(lambda_event, max_records=20),
},
)
return f"exception raised: {e.__repr__()}"