Skip to content

Commit

Permalink
tracing config
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer committed Dec 21, 2024
1 parent bc19f3c commit a0af52a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 7 additions & 2 deletions packages/aws-cdk-lib/aws-synthetics/lib/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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', () => {
Expand Down

0 comments on commit a0af52a

Please sign in to comment.