Configure Response Header Mappings
Configure response header mappings to pass ADRUM_n
headers back to
the browser. You can configure response header mappings:
- Using the AWS API Gateway
- Passing directly via AWS Lambda Proxy Integration
- Returning EUM metadata in your function code
Response Header Mappings in Amazon API Gateway
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
|
Response Header Mappings in AWS Lambda Proxy Integration
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.
Response Header Mappings for All Other Invocations
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);
}