Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(resolve => {
AWSXRay.setDaemonAddress('127.0.0.1:2000');
AWSXRay.enableAutomaticMode();
const segment = new AWSXRay.Segment('aws-xray-lambda-promise-subsegment');
const namespace = AWSXRay.getNamespace();
namespace.run(async function () {
AWSXRay.setSegment(segment);
console.log('segment', segment);
try {
await functionToHaveTraced(segment);
segment.close();
} catch (error) {
console.error(error);
segment.close(error);
}
resolve();
});