Skip to content

All shutdown events are reported with a failure outcome #411

@julianolf

Description

@julianolf

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:

  1. Spin up multiple instances of a Lambda function (two or more).
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws-λ-extensionAWS Lambda ExtensionbugSomething isn't workingcommunityIssues and PRs created by the communitytriageIssues and PRs that need to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions