captureAsyncFunc is not working for AWS Lambda with runtime nodejs 16
ujasur opened this issue · comments
Jasur commented
I am experiencing strange issue with using captureAsyncFunc
in my code that runs on aws lambda nodejs16x runtime.
Here is my environment:
- Lambda runtime is nodejs16.x
- The config for active tracing with XRAY is on. I see some traces but not the ones with
captureAsyncFunc
- The lambda zip package is built with
public.ecr.aws/lambda/nodejs:16
docker image - The
aws-xray-sdk
is3.5.1
and this only npm package dependencies of my code. - If I remove the
xray.captureHTTPsGlobal(require('https'));
line, the#perform
segment is shown on tracing graph in aws console however the url is not shown. - Below attached my code
const xray = require('aws-xray-sdk');
xray.captureHTTPsGlobal(require('https'));
const https = require('https');
async function doWork() {
await xray.captureAsyncFunc('perform', async (subsegment) => {
const resp = await https.get('https://encrypted.google.com/');
subsegment.close();
console.log('fetched', resp.status);
});
}
exports.handler = async (event, context) => {
await doWork( event, context);
};
Carol Abadeer commented
Can you try adding xray.capturePromise()
before your xray.captureAsyncFunc()
call? I was able to see the perform
subsegment after adding this line (see this related issue for more information)