awslabs / awslabs/llrt

Problems with 'aws-xray-sdk-core'

Open
#628 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
8.8k
Forks
393
Avg merge
1d 11h
Merged PRs (30d)
45

Description

Hi,

I have this small lambda function:
```typescript
import {ListBucketsCommand, S3Client} from "@aws-sdk/client-s3";

export const handle = async () => {
const s3Client = new S3Client();
const rest = await s3Client.send(new ListBucketsCommand());
rest.Buckets?.forEach(bucket => {
console.log(bucket.Name);
});
console.log('Hello world');
}
```
which works great.

But when I want to capture calls to S3 with X-Ray traces using the `aws-xray-sdk-core` library:
```typescript
import {captureAWSv3Client} from 'aws-xray-sdk-core';
...
const s3Client = captureAWSv3Client(new S3Client());
....
```

it starts failing with error:
```
2024-10-14T20:11:17.555Z n/a FATAL ReferenceError: Error resolving module '/var/task/assert' from '/var/task/index.mjs'
at (/var/task/index.mjs:1:4249)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:16634)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:89512)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:91308)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:91325)
INIT_REPORT Init Duration: 62.39 ms Phase: init Status: error Error Type: Runtime.ExitError
2024-10-14T20:11:18.415Z n/a FATAL ReferenceError: Error resolving module '/var/task/assert' from '/var/task/index.mjs'
at (/var/task/index.mjs:1:4249)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:16634)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:89512)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:91308)
at (/var/task/index.mjs:1:458)
at (/var/task/index.mjs:6:91325)
INIT_REPORT Init Duration: 934.90 ms Phase: invoke Status: error Error Type: Runtime.ExitError
START RequestId: 40310a38-3d40-4569-a631-e8e103a5105c Version: $LATEST
RequestId: 40310a38-3d40-4569-a631-e8e103a5105c Error: Runtime exited with error: exit status 1
Runtime.ExitError
END RequestId: 40310a38-3d40-4569-a631-e8e103a5105c
REPORT RequestId: 40310a38-3d40-4569-a631-e8e103a5105c Duration: 975.40 ms Billed Duration: 976 ms Memory Size: 128 MB Max Memory Used: 19 MB
XRAY TraceId: 1-670d7ae5-67eb6e644cea659b394342d3 SegmentId: 44f97b661735d32b Sampled: true
```

Lambda function is created using `cdk-lambda-llrt` cdk construct:
```typescript
import {LlrtBinaryType, LlrtFunction} from "cdk-lambda-llrt";

class MyLambda extends LlrtFunction {
constructor(scope: Construct, id: string) {
super(scope, id, {
entry: path.resolve(__dirname, './handlers/my-lambda.ts'),
handler: 'handle',
llrtBinaryType: LlrtBinaryType.FULL_SDK,
tracing: Tracing.ACTIVE,
architecture: cdk.aws_lambda.Architecture.ARM_64,
});
this.addToRolePolicy(new cdk.aws_iam.PolicyStatement({
actions: ['s3:*'],
resources: ['*'],
}));
}
}
```

Any idea what the problem might be and how to solve it?

Contributor guide

Open the contributing guide

Research direction

Start with handlers/my-lambda.ts and the LlrtFunction configuration using LlrtBinaryType.FULL_SDK; reproduce the failure by comparing a plain S3Client with captureAWSv3Client. Check how aws-xray-sdk-core resolves assert in the LLRT Lambda bundle. Done means the function initializes successfully and the S3 call is captured in X-Ray.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
backend, cloud, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.