Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
});
session.run(function() {
AWSXRay.setSegment(subsegment);
cb(err, data);
});
session.run(function() {
AWSXRay.setSegment(subsegment);
cb(err, data);
});
axios.interceptors.request.use(function (config) {
var parent = xray.getSegment();
var subsegment = parent.addNewSubsegment(config.baseURL + config.url.substr(1));
subsegment.namespace = 'remote';
let root = parent.segment ? parent.segment : parent;
let header = 'Root=' + root.trace_id + ';Parent=' + subsegment.id + ';Sampled=' + (!root.notTraced ? '1' : '0');
config.headers.get={ 'x-amzn-trace-id': header };
config.headers.post={ 'x-amzn-trace-id': header };
xray.setSegment(subsegment);
return config;
}, function (error) {
var subsegment = xray.getSegment().addNewSubsegment("Intercept request error");
ns.run(function () {
AWSXRay.setSegment(segment);
if (next) { next(); }
});
} else {