Skip to content

Commit d4a8353

Browse files
Merge pull request #20201 from bizob2828/node-lambda-updates
chore: Updated language around using Node.js lambda layer with ESM
2 parents 96d0093 + 26d1af8 commit d4a8353

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/containerized-images.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ redirects:
77
freshnessValidatedDate: never
88
---
99

10-
If you're using a containerized image for a Lambda function and want to monitor your application, you'll need to add a pre-built [New Relic Lambda layer](https://gallery.ecr.aws/newrelic-lambda-layers-for-docker?page=1) to your Dockerfile that matches your function's runtime.
10+
If you're using a containerized image for a Lambda function and want to monitor your application, you'll need to add a pre-built [New Relic Lambda layer](https://gallery.ecr.aws/newrelic-lambda-layers-for-docker?page=1) to your Dockerfile that matches your function's runtime.
1111

1212
Here's a diagram showing the process of adding New Relic to the Dockerfile so you can monitor your function:
1313

@@ -122,6 +122,8 @@ Here's a guide to adding our pre-built layer to your code.
122122

123123
# CMD override to New Relic's handler wrapper
124124
CMD [ "newrelic-lambda-wrapper.handler" ]
125+
# If your lambda function is ESM, use the New Relic's Node.js ESM handler wrapper
126+
# CMD ["/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler"]
125127
```
126128
Try out [working example](https://github.com/newrelic/newrelic-lambda-extension/tree/main/examples/sam/containerized-lambda/nodejs-sam-example) of a Node.js containerized Lambda function using SAM.
127129
</TabsPageItem>

src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/env-variables-lambda.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Based on your runtime, you can set the following environment variables to furthe
7373
<td>`NEW_RELIC_USE_ESM`</td>
7474
<td>`false`</td>
7575
<td>`true`, `false`</td>
76-
<td>**Required**: Enable ESM functions that use async/await and not callbacks by setting this to `true`</td>
76+
<td>**DEPRECATED**: This will be removed from future versions of the Node.js lambda layer. Instead set your handler to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`</td>
7777
</tr>
7878
<tr>
7979
<td>`NODE_OPTIONS`</td>
@@ -293,7 +293,7 @@ You can find more environment variables in our [Python configuration documentati
293293
<td>`/opt/lib/newrelic-dotnet-agent/libNewRelicProfiler.so`</td>
294294
<td>**Required**: Set this to `/opt/lib/newrelic-dotnet-agent/libNewRelicProfiler.so` to enable the .NET agent</td>
295295
</tr>
296-
296+
297297
<tr>
298298
<td>`NEW_RELIC_DISTRIBUTED_TRACING_ENABLED`</td>
299299
<td>`true`</td>
@@ -411,7 +411,7 @@ See more environment variables for the New Relic extension in our [documentation
411411
</TabsPageItem>
412412

413413

414-
</TabsPages>
414+
</TabsPages>
415415
</Tabs>
416416

417417
## What's next

src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/instrument-your-own.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Depending on your needs, you can choose to either bypass the extension and only
158158
// Add latest New Relic Lambda layer ARN from https://layers.newrelic-external.com
159159
const NewReliclayerArn = 'arn:aws:lambda:us-east-1:451483290750:layer:NewRelicNodeJS20X:39';
160160
const myFunction = new lambda.Function(this, "NewRelicExampleLambda", {
161-
runtime: lambda.Runtime.NODEJS_20_X,
161+
runtime: lambda.Runtime.NODEJS_20_X,
162162
// Update functions handler to point to the New Relic Lambda wrapper
163163
handler: "newrelic-lambda-wrapper.handler",
164164
code: lambda.Code.fromAsset('lib/lambda-runtime-code'),
@@ -226,7 +226,9 @@ Depending on your needs, you can choose to either bypass the extension and only
226226
* `RequestHandler` implementation: `com.newrelic.java.HandlerWrapper::handleRequest`.
227227
* `RequestStreamHandlerWrapper` implementation: `com.newrelic.java.HandlerWrapper::handleStreamsRequest`.
228228
* Python: `newrelic_lambda_wrapper.handler` (underscores).
229-
* Node: `newrelic-lambda-wrapper.handler` (hyphens).
229+
* Node:
230+
* CommonJS: `newrelic-lambda-wrapper.handler` (hyphens).
231+
* ESM: `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler` (hyphens).
230232
* For .Net you don't have to set the handler.
231233

232234
Note that for Go, you must make source code changes to your Lambda function to instrument it. Configuration changes are not enough.
@@ -263,4 +265,4 @@ Depending on your needs, you can choose to either bypass the extension and only
263265
<DocTile title="Compatibility and requirement" path="/docs/serverless-function-monitoring/aws-lambda-monitoring/instrument-lambda-function/compatibility-requirement-lambda-monitoring">Learn more about supported runtimes and prerequisites</DocTile>
264266
<DocTile title="Data and UI" path="/docs/serverless-function-monitoring/aws-lambda-monitoring/ui-data/understand-lambda-monitoring-ui/" >Learn how to use New Relic to monitor your AWS Lambda functions</DocTile>
265267
<DocTile title="Troubleshooting" path="/docs/serverless-function-monitoring/aws-lambda-monitoring/troubleshooting" >Learn how to troubleshoot installation related issues</DocTile>
266-
</DocTiles>
268+
</DocTiles>

src/content/docs/serverless-function-monitoring/aws-lambda-monitoring/troubleshooting/troubleshoot-enabling-serverless-monitoring-aws-lambda.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Besides these basic enablement problems, there are some additional problems that
3131

3232
* If you're instrumenting with layers: make sure in your function configuration that the New Relic layer is merged before other layers (though if your function uses webpack, the New Relic layer should be merged after the webpack layer).
3333
* If you're instrumenting a Node.js function manually, make sure that [logging is enabled](/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration/#logging_config), and that your function imports <DNT>**newrelic**</DNT> before it imports any dependencies you expect to monitor.
34-
* If you're using ES Modules with a Node.js function, make sure that the environment variable `NEW_RELIC_USE_ESM` is set to `true`. Additionally, make sure you're using async/await or promises for handling asynchronous behavior in your function, as callback-based functions are not supported when using ES Modules.
34+
* If you're using ES Modules with a Node.js function, make sure to change the handler function to `/opt/nodejs/node_modules/newrelic-esm-lambda-wrapper/index.handler`. Additionally, set the environment variable of `NODE_PATH` to `--experimental-loader newrelic/esm-loader.mjs`.
3535

3636
If none of these solutions help you, contact our [support team](https://support.newrelic.com/). The following information will help you when you talk to support technicians:
3737

0 commit comments

Comments
 (0)