Skip to content

Commit 9a4fc51

Browse files
committed
Added patch AWS SDK clients to manual e2e test
1 parent 682d62c commit 9a4fc51

File tree

7 files changed

+5870
-3695
lines changed

7 files changed

+5870
-3695
lines changed

examples/cdk/lib/example-function.Tracer.PatchAWSSDKv2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const tracer = new Tracer({ serviceName: 'tracerPatchAWSSDKv2Fn' });
88
// To patch a specific AWS SDK Client, we pass it to the Tracer that will return an instrumented version of it
99
const sts = tracer.captureAWSClient(new STS());
1010

11-
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context) => {
11+
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context): Promise<unknown> => {
1212
const segment = tracer.getSegment(); // This is the facade segment (the one that is created by AWS Lambda)
1313
// Create subsegment for the function & set it as active
1414
const subsegment = segment.addNewSubsegment(`## ${process.env._HANDLER}`);

examples/cdk/lib/example-function.Tracer.PatchAWSSDKv3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const tracer = new Tracer({ serviceName: 'tracerManualFn' });
88
// To patch a specific AWS SDK v3 Client, we need to pass it to the Tracer that will return an instrumented version of it
99
const sts = tracer.captureAWSv3Client(new STSClient({}));
1010

11-
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context) => {
11+
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context): Promise<unknown> => {
1212
const segment = tracer.getSegment(); // This is the facade segment (the one that is created by AWS Lambda)
1313
// Create subsegment for the function & set it as active
1414
const subsegment = segment.addNewSubsegment(`## ${process.env._HANDLER}`);

examples/cdk/lib/example-function.Tracer.PatchAllAWSSDK.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { Tracer } from '@aws-lambda-powertools/tracer';
55
// process.env.POWERTOOLS_SERVICE_NAME = 'tracerManualFn'; // Alternative to setting the service name in the constructor
66
const tracer = new Tracer({ serviceName: 'tracerPatchAllAWSSDKFn' });
77
// To patch all AWS SDKs, we need to import aws-sdk and pass it to the Tracer
8+
// eslint-disable-next-line @typescript-eslint/no-var-requires
89
const AWS = tracer.captureAWS(require('aws-sdk'));
910
// Then we can use the AWS SDK as usual
1011
const sts = new AWS.STS();
1112

12-
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context) => {
13+
export const handler = async (_event: typeof Events.Custom.CustomEvent, _context: Context): Promise<unknown> => {
1314
const segment = tracer.getSegment(); // This is the facade segment (the one that is created by AWS Lambda)
1415
// Create subsegment for the function & set it as active
1516
const subsegment = segment.addNewSubsegment(`## ${process.env._HANDLER}`);

0 commit comments

Comments
 (0)