aws / aws/aws-xray-sdk-node

captureAsyncFunc is not working for AWS Lambda with runtime nodejs 16

Open
#613 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
280
Forks
157
PR merge metrics
No merged PRs in 30d

Description

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);
};

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.