Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/xray.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const xray = require('aws-xray-sdk-core');

exports.captureWithXRay = () => {
if (process.env.LAMBDA_TASK_ROOT) {
xray.captureHTTPsGlobal(require('http'));
xray.captureAWS(require('aws-sdk'));
xray.capturePromise();
}
// We are passing in the client AWS-SDK in order to avoid version conflict.
// If the calling project and lambda-tools do not agree on the AWS-SDK version then the
// caller's SDK instance will not get instrumented and there will not be any warning.
exports.captureWithXRay = function (awsSdk) {
xray.captureHTTPsGlobal(require('http'));
xray.capturePromise();
return xray.captureAWS(awsSdk);
};