Exit Call Error Reports

By default, the tracer automatically discovers exit calls passed over HTTP or inter-AWS1 Lambda calls. Use the reportExitCallError method to report errors and exceptions that occur during exit call execution.

The following code snippet demonstrates how to create an exit call error report:

// Use the Exit Call API in your AWS Lambda handler function
module.exports.myLambdaHandler = async function () {
const queryPromise = new Promise(function (resolve, reject) {
const dbConfig = {
host: '127.0.0.1', // The host where your MySQL server runs
port: 3306, // Note that this is not an identifying property. Identifying properties must be strings
user: 'root',
database: 'movies'
};
const mysql = require('mysql');
const mysqlClient = mysql.createPool(dbConfig);
mysqlClient.getConnection(function (err, connection) {
if (err) {
reject({
statusCode: 500,
body: 'Couldn\'t make the connection to mysql client.'
});
return;
}
// Create an Exit Call
var exitCall = tracer.startExitCall({
exitType: 'DB',
exitSubType: 'DB',
identifyingProperties: {
'HOST': '127.0.0.1', // The host where your MySQL server runs
'PORT': '3306',
'DATABASE': 'movies',
'VENDOR': 'MYSQL'
}
});
connection.query('SELECT * FROM ClassicHits', function (err, results) {
connection.release();
//Create an Exit Call error report
if (err) {
tracer.reportExitCallError(exitCall, 'MYSql error', 'Failed in making the query');
reject({
statusCode: 500,
body: 'Mysql query failed'
});
return;
}
resolve({
statusCode: 200,
body: JSON.stringify(results)
});
});
});
});
return queryPromise;
}
1 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.