Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

captureAsyncFunc is not working for AWS Lambda with runtime nodejs 16 #613

Open
ujasur opened this issue Sep 19, 2023 · 1 comment
Open

Comments

@ujasur
Copy link

ujasur commented Sep 19, 2023

I am experiencing strange issue with using captureAsyncFunc in my code that runs on aws lambda nodejs16x runtime.
Here is my environment:

  1. Lambda runtime is nodejs16.x
  2. The config for active tracing with XRAY is on. I see some traces but not the ones with captureAsyncFunc
  3. The lambda zip package is built with public.ecr.aws/lambda/nodejs:16 docker image
  4. The aws-xray-sdk is 3.5.1 and this only npm package dependencies of my code.
  5. 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.
  6. 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);
};

@carolabadeer
Copy link
Contributor

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants