-
Notifications
You must be signed in to change notification settings - Fork 35
Description
APM AWS Lambda extensiom version (elastic-apm-extension-ver-1-5-0-x86_64
):
Describe the bug
When AWS Lambda service sends a shutdown event to a function the extension captures it and no matter the reason for the shutdown the event outcome is set as failure
.
To Reproduce
Steps to reproduce the behavior:
- Spin up multiple instances of a Lambda function (two or more).
- Wait a few minutes for the Lambda service start to scale down (shutting down due spin down).
Expected behavior
Elastic receives transactions where the event.outcome
is failure
and the transaction.result
is spindown
.
Provide logs (if relevant): https://gist.github.com/julianolf/33dcd000be2363300879e434080b4c7f
Assumption
I believe the previous versions of the extension wasn't actually handling the shutdown event, this started to happen after upgrading to version 1.5 and it seems to be related to some working in progress related to this issue #118.
According to AWS documentation there are three possibilities for a shutdown, spindown
is just a normal shutdown.
As a temporary fix I've patched this single line.
diff --git a/accumulator/invocation.go b/accumulator/invocation.go
index 2895046..40e2419 100644
--- a/accumulator/invocation.go
+++ b/accumulator/invocation.go
@@ -79,7 +79,7 @@ func (inc *Invocation) MaybeCreateProxyTxn(status string, time time.Time) ([]byt
if err != nil {
return nil, err
}
- if status != "success" {
+ if status != "success" && status != "spindown" {
txn, err = sjson.SetBytes(txn, "transaction.outcome", "failure")
if err != nil {
return nil, err
PS.
If my steps to reproduce are too vague I can provide a small example projecto using AWS SAM to help easily reproduce what I've described.
Also, I could help on fixing it if it makes sense and you guys are willing to give some orientation on how to proceed, just let me know.