This document contains links to AWS documentation. |
Serverless APM for AWS Lambda is designed to integrate with your existing End User Monitoring (EUM) configurations. EUM integration provides complete end-to-end visibility on the performance of your web and mobile applications, linking calls from an end-user device through your serverless functions to continue your business transactions
AWS Lambda functions can correlate EUM and AWS Lambda-originated business transactions, in conjunction with the following EUM agents:
This document assumes you are familiar with |
Ensure your deployment has:
By default, EUM integration is turned off for the Node.js Serverless Tracer.
To enable EUM integration, set the APPDYNAMICS_ENABLE_EUM
environment variable to true
. See Set Up the Serverless APM Environment for more details.
Configure response header mappings to pass ADRUM_n
headers back to the browser. You can configure response header mappings:
Add header mappings for each ADRUM_n
header in the Amazon API Gateway. See Amazon API Gateway API request and response data mapping reference.
The table below lists the required response headers and their mapping values:
Response Header | Mapping Value |
---|---|
ADRUM_3 | integration.response.body.headers.ADRUM_3 |
ADRUM_2 | integration.response.body.headers.ADRUM_2 |
ADRUM_1 | integration.response.body.headers.ADRUM_1 |
ADRUM_0 | integration.response.body.headers.ADRUM_0 |
As an alternative to custom integration, AWS Lambda proxy integration allows the client to call each function in the backend and returns output in a JSON format. Map these responses by adding each single-value ADRUM_n header directly to the headers field in your output object class. Refer to the Amazon documentation for details.
To gather EUM metadata, you need to configure response header mappings. This code sample invokes an appDEumHeaders
method on the tracer. This method returns an object containing the ADRUM_n headers. Pass this object to the downstream service for consumption by the downstream JavaScript Agent.
The code snippet below demonstrates how you can return EUM metadata:
module.exports.myLambdaHandler = function (event, context, callback) { setTimeout(function () { ////Call a transaction object let appDBusinessTxn = tracer.getCurrentTransaction(); //Stop the transaction tracer.stopTransaction(); //Return EUM Metadata let appDEumHeaders = tracer.getEumMetadata(appDBusinessTxn); callback(null, { eumMetadata: appDEumHeaders, data: 'Call to Lambda is a success' }); }, 300); } |
To see the correlation between EUM and AWS Lambda-originated business transactions, you must inject the JavaScript Agent into your browser's HTML, as described in Inject the JavaScript Agent.
Browsers require cross-origin resource sharing (CORS) for functions that access responses from browser requests to a domain other than the base page's domain. You must explicitly grant cross-domain access to all applicable ADRUM_n
headers.
To enable CORS configuration, follow these steps:
ADRUM_0
through ADRUM_3
to be compatible with the JavaScript Agent. For example, ADRUM_0
, ADRUM_1
, ADRUM_2
, ADRUM_3
.Access-Control-Allow-Methods - select the header(s) with the appropriate method. For example, POST
, OPTIONS
.
'http://my-saas-service.com:8000'
.Access-Control-Expose-Headers: `ADRUM_0,ADRUM_1,ADRUM_2,ADRUM_3`
Access-Control-Allow-Credentials: `true`
Access-Control-Allow-Methods: `POST,OPTIONS`
Access-Control-Allow-Origin: `http://my-saas-service.com:8000`
(Optional) If you connect your function to the Amazon API Gateway via a proxy integration, define the CORS response header mappings in your function code:
//Return EUM Metadata let appDEumHeaders = tracer.getEumMetadata(appDBusinessTxn); let returnHeaders = { 'Access-Control-Allow-Origin': 'http://my-saas-service.com:8000', 'Access-Control-Allow-Credentials': true, 'Access-Control-Expose-Headers': 'ADRUM_0,ADRUM_1,ADRUM_2,ADRUM_3' }; |
If you do not see a correlation between EUM data and business transactions, collect an HTTP Archive (HAR) file that captures the activity in your browser. Use the HAR file to confirm all necessary CORS headers are set and expected data populates in the ARUM_n headers.
The EUM documentation provides additional troubleshooting advice.
Amazon Web Services, the AWS logo, AWS, and any other AWS Marks used in these materials are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.