From a0af52a5d740885378a70eac8f82e48982553bbb Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 22 Dec 2024 07:50:22 +0900 Subject: [PATCH] tracing config --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 9 +++++++-- packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 3d95b6663fb5d..f920cf09c98a5 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -589,8 +589,13 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { } // Only check runtime family is nodejs because versions prior to syn-nodejs-2.0 are deprecated and can no longer be configured. - if (props.activeTracing && !cdk.Token.isUnresolved(props.runtime.family) && props.runtime.family !== RuntimeFamily.NODEJS) { - throw new Error('You can only enable active tracing for canaries that use canary runtime version `syn-nodejs-2.0` or later.'); + if ( + props.activeTracing && + !cdk.Token.isUnresolved(props.runtime.family) && + !cdk.Token.isUnresolved(props.runtime.name) && + (props.runtime.family !== RuntimeFamily.NODEJS || props.runtime.name.includes('playwright')) + ) { + throw new Error(`You can only enable active tracing for canaries that use canary runtime version 'syn-nodejs-2.0' or later and are not using the Playwright runtime, got ${props.runtime.name}.`); } let memoryInMb: number | undefined; diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 554553c2be01c..871d0069d15ff 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -260,7 +260,10 @@ test.each([true, false])('activeTracing can be set to %s', (activeTracing: boole }); }); -test('throws when activeTracing is enabled with an unsupported runtime', () => { +test.each([ + synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, + synthetics.Runtime.SYNTHETICS_NODEJS_PLAYWRIGHT_1_0, +])('throws when activeTracing is enabled with an unsupported runtime', (runtime) => { // GIVEN const stack = new Stack(); @@ -270,10 +273,10 @@ test('throws when activeTracing is enabled with an unsupported runtime', () => { handler: 'index.handler', code: synthetics.Code.fromInline('# Synthetics handler code'), }), - runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, + runtime, activeTracing: true, })) - .toThrow('You can only enable active tracing for canaries that use canary runtime version `syn-nodejs-2.0` or later.'); + .toThrow(`You can only enable active tracing for canaries that use canary runtime version 'syn-nodejs-2.0' or later and are not using the Playwright runtime, got ${runtime.name}.`); }); test('environment variables can be specified', () => {