From bed35d16ab2f83e42a79338b524157c818f2bf19 Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Thu, 3 Mar 2022 10:19:36 -0800 Subject: [PATCH 1/7] feat: update for Node ARN and function wrapping --- docs/aws-lambda-extension.asciidoc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index 2979981a..38c0fa80 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -98,13 +98,27 @@ For a _minimal configuration_ you need to specify the `ELASTIC_APM_LAMBDA_APM_SE [[aws-lambda-handler]] === Configuring the Agent and Lambda Function handler -Once you've installed the extension, there's one last step to take. You'll need to wrap the Lambda function handler. +Once you've installed the extension, there's one last step to take. You'll need to install the correct language agent and wrap the Lambda function handler. + [discrete] [[aws-lambda-nodejs]] ==== Node.js -In Node.js, you wrap a Lambda function handler using the following syntax. +To install the Node.js agent in Lambda you'll use a second layer. You'll need to https://github.com/elastic/apm-agent-nodejs/releases[pick the right ARN from the agent release table]. The ARN has the pattern `arn:aws:lambda::267093732750:layer:elastic-apm-node-ver-3--0:` and depends on: + +* The AWS region your Lambda function runs in. The APM Lambda Extension layer needs to be in the same region as your Lambda function. +* The version of the APM Lambda Extension you would like to use. + +You'll then need to configure your function to use that layer. To add a layer + +1. Navigate to your function in the AWS Console +2. Scroll to the Layers section and click the _Add a layer_ button image:images/config-layer.png[image of layer configuration section in AWS Console] +3. Choose the _Specify an ARN_ radio button +4. Enter the Version ARN of the APM Lambda Extension layer in the _Specify an ARN_ text input +5. Click the _Add_ button + +The Node.js agent will wrap your Lambda function handler automatically. You can also use the following syntax to manually wrap the handler. [source,js] ---- @@ -140,6 +154,6 @@ See the {apm-py-ref}/lambda-support.html[Python agent setup guide] for detailed [[aws-lambda-java]] ==== Java -Like the extension, the Elastic APM Java agent is installed as a Lambda layer. +Like the extension, the Elastic APM Java agent is installed as a Lambda layer. See the {apm-java-ref}/aws-lambda.html[Java agent setup guide] for detailed instructions on setting up the Java agent for AWS Lambda. From 15071fdd900e5401ed7e16e8cbe759e33641ed99 Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Thu, 3 Mar 2022 10:21:35 -0800 Subject: [PATCH 2/7] fix: version --- docs/aws-lambda-extension.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index 38c0fa80..64a24aab 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -105,7 +105,7 @@ Once you've installed the extension, there's one last step to take. You'll need [[aws-lambda-nodejs]] ==== Node.js -To install the Node.js agent in Lambda you'll use a second layer. You'll need to https://github.com/elastic/apm-agent-nodejs/releases[pick the right ARN from the agent release table]. The ARN has the pattern `arn:aws:lambda::267093732750:layer:elastic-apm-node-ver-3--0:` and depends on: +To install the Node.js agent in Lambda you'll use a second layer. You'll need to https://github.com/elastic/apm-agent-nodejs/releases[pick the right ARN from the agent release table]. The ARN has the pattern `arn:aws:lambda::267093732750:layer:elastic-apm-node-ver--0:` and depends on: * The AWS region your Lambda function runs in. The APM Lambda Extension layer needs to be in the same region as your Lambda function. * The version of the APM Lambda Extension you would like to use. From a8dd9bd78c6b3fe1b2a30d9ea7162f65d9530ae1 Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Thu, 3 Mar 2022 10:30:33 -0800 Subject: [PATCH 3/7] doc: add env var --- docs/aws-lambda-extension.asciidoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index 64a24aab..ef269749 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -118,7 +118,14 @@ You'll then need to configure your function to use that layer. To add a layer 4. Enter the Version ARN of the APM Lambda Extension layer in the _Specify an ARN_ text input 5. Click the _Add_ button -The Node.js agent will wrap your Lambda function handler automatically. You can also use the following syntax to manually wrap the handler. +Finally, to have the the Node.js automatically wrap your Lambda function handler, just add the following environment variable. + +[source] +--- +NODE_OPTIONS=-r elastic-apm-node/start +--- + +You can also use the following syntax to manually wrap the handler. [source,js] ---- From 0ff39f222e407a18b0c9865b6b66d509099f109b Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Wed, 9 Mar 2022 08:57:47 -0800 Subject: [PATCH 4/7] Update docs/aws-lambda-extension.asciidoc Co-authored-by: Trent Mick --- docs/aws-lambda-extension.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index ef269749..1753a0d0 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -105,7 +105,7 @@ Once you've installed the extension, there's one last step to take. You'll need [[aws-lambda-nodejs]] ==== Node.js -To install the Node.js agent in Lambda you'll use a second layer. You'll need to https://github.com/elastic/apm-agent-nodejs/releases[pick the right ARN from the agent release table]. The ARN has the pattern `arn:aws:lambda::267093732750:layer:elastic-apm-node-ver--0:` and depends on: +To install the Node.js agent in Lambda you'll use a second layer. You'll need to https://github.com/elastic/apm-agent-nodejs/releases[pick the right ARN from the agent release table]. The ARN has the pattern `arn:aws:lambda::267093732750:layer:elastic-apm-node-ver-:` and depends on: * The AWS region your Lambda function runs in. The APM Lambda Extension layer needs to be in the same region as your Lambda function. * The version of the APM Lambda Extension you would like to use. From b88a28d7f7b0246eb7f3a110b286db9ba97543c3 Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Wed, 9 Mar 2022 08:58:14 -0800 Subject: [PATCH 5/7] Update docs/aws-lambda-extension.asciidoc Co-authored-by: Brandon Morelli --- docs/aws-lambda-extension.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index 1753a0d0..443f8cd3 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -118,7 +118,7 @@ You'll then need to configure your function to use that layer. To add a layer 4. Enter the Version ARN of the APM Lambda Extension layer in the _Specify an ARN_ text input 5. Click the _Add_ button -Finally, to have the the Node.js automatically wrap your Lambda function handler, just add the following environment variable. +Finally, to have the Node.js agent automatically wrap your Lambda function handler, add the following environment variable. [source] --- From c118e47cd06aa206d06e9c0ac309905686dda19c Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Wed, 9 Mar 2022 08:58:23 -0800 Subject: [PATCH 6/7] Update docs/aws-lambda-extension.asciidoc Co-authored-by: Brandon Morelli --- docs/aws-lambda-extension.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index 443f8cd3..c069623c 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -98,7 +98,7 @@ For a _minimal configuration_ you need to specify the `ELASTIC_APM_LAMBDA_APM_SE [[aws-lambda-handler]] === Configuring the Agent and Lambda Function handler -Once you've installed the extension, there's one last step to take. You'll need to install the correct language agent and wrap the Lambda function handler. +After the extension has been installed, install the relevant language agent and wrap the Lambda function handler. [discrete] From 80c9342272a2eb28441a263faa6524ce214a42e1 Mon Sep 17 00:00:00 2001 From: Alan Storm Date: Wed, 9 Mar 2022 09:03:28 -0800 Subject: [PATCH 7/7] fix: remove manual handler wrapping --- docs/aws-lambda-extension.asciidoc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/docs/aws-lambda-extension.asciidoc b/docs/aws-lambda-extension.asciidoc index c069623c..71f08eb9 100644 --- a/docs/aws-lambda-extension.asciidoc +++ b/docs/aws-lambda-extension.asciidoc @@ -125,20 +125,6 @@ Finally, to have the Node.js agent automatically wrap your Lambda function handl NODE_OPTIONS=-r elastic-apm-node/start --- -You can also use the following syntax to manually wrap the handler. - -[source,js] ----- -const apm = require('elastic-apm-node').start({/*...*/}) -exports.handler = apm.lambda(async function handler (event, context) { - const response = { - statusCode: 200, - body: "hello new async." - }; - return response -}) ----- - See the {apm-node-ref}/lambda.html[Node.js agent setup guide] for detailed instructions on setting up the Node.js agent for AWS Lambda. [discrete]