aws-samples / aws-lambda-extensions

A collection of sample extensions to help you get started with AWS Lambda Extensions
MIT No Attribution
442 stars 145 forks source link

Java Lambda Telemetry API extension:- Exception in lambda, platform.RuntimeDone status is success instead of failure #85

Closed bajajyog closed 11 months ago

bajajyog commented 1 year ago

We have built a Java Lambda extension and subscribing to telemetry api to push logs to splunk. An explicit exception is thrown in lambda to check telemetry api show status as failure for Lambda exception in the platform.runTimeDone event.

AWS lambda Telemetry api msgs:-

{ "time": "2023-06-11T17:03:14.843Z", "type": "function", "record": "exception: .infrastructure.exception.ServerlessException\ncom.infrastructure.exception.ServerlessException: exception\ .... } , { "time": "2023-06-11T17:03:14.843Z", "type": "platform.runtimeDone", "record": { "requestId": "777ff55f-e84c-41f8-ae9f-53f541f01a60", "status": "success", "metrics": { "durationMs": 78.656, "producedBytes": 0 } } }

Please advise, why platform.runtimeDone event status is success instead of failure for explicit exception in lambda or please advise in. which cases of invocation failure we will get status as failure in platform.runtimeDone event.

julianwood commented 1 year ago

The behavior that you report is as intended (though we acknowledge how it might come across as confusing). The runtime catches the error thrown by your function handler, and reports this error as described in Runtime API invoke error behavior as described here. From the Runtime’s perspective, this request executed successfully (i.e. did not crash, timeout, or exit), hence status=success. We’re evaluating ways to better surface errors that occur in function code, but don’t currently have a timeline for it. Hope this helps, and let me know if you have any other questions.