diff --git a/src/xray.js b/src/xray.js index 644113d6..52570088 100644 --- a/src/xray.js +++ b/src/xray.js @@ -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); };