Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sns): add TracingConfig prop #29715

Closed
wants to merge 0 commits into from
Closed

Conversation

jun1-t
Copy link
Contributor

@jun1-t jun1-t commented Apr 4, 2024

Issue # (if applicable)

Closes #29714

Reason for this change

Currently, to set the TracingConfig, it is necessary to configure it via L1.
So, add TracingConfig props to L2.

Description of changes

added TracingConfig props to topic.ts, sns.test.ts, integ.sns.ts, and README.md for AWS SNS.

Description of how you validated changes

I confirmed with unit test and integ test that it works as expected.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2 labels Apr 4, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team April 4, 2024 00:12
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 4, 2024
Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use an enum here, it makes for stronger typing, a simpler implementation for your PR, better DX, better documentation, etc

* If PassThrough, the topic passes trace headers received from the Amazon SNS publisher to its subscription.
* If set to Active, Amazon SNS will vend X-Ray segment data to topic owner account if the sampled flag in the tracing header is true.
*
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-active-tracing.html.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The period at the end breaks the URL

Suggested change
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-active-tracing.html.
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-active-tracing.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

*
* @default PassThrough
*/
readonly tracingConfig?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An enumeration would be preferred here, since only two values are acceptable. Although I'm not sure why it's not properly documented in the CloudFormation docs, there should be a list of "Valid Values"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed to enum.

Comment on lines 251 to 258
if (
props.tracingConfig &&
!Token.isUnresolved(props.tracingConfig) &&
props.tracingConfig !== 'PassThrough' &&
props.tracingConfig !== 'Active'
) {
throw new Error(`tracingConfig must be "PassThrough" or "Active", received: "${props.tracingConfig}".`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enumeration also allows your to remove this check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

Comment on lines 780 to 789
test('throw with incorrect tracingConfig', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app);

expect(
() => new sns.Topic(stack, 'MyTopic', {
tracingConfig: 'Test',
}),
).toThrow(/tracingConfig must be "PassThrough" or "Active", received: "Test"./);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can also be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 4, 2024
@nmussy
Copy link
Contributor

nmussy commented Apr 4, 2024

Did you forget to push your latest commits?

@jun1-t
Copy link
Contributor Author

jun1-t commented Apr 4, 2024

Did you forget to push your latest commits?

Failed build after code fix.
Please wait.

Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small stuff, LGTM otherwise 👍

/**
* The mode that topic passes trace headers received from the Amazon SNS publisher to its subscription.
*/
PASSTHROUGH = 'PassThrough',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PASSTHROUGH = 'PassThrough',
PASS_THROUGH = 'PassThrough',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

*
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-active-tracing.html
*
* @default PassThrough
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @default PassThrough
* @default TracingConfig.PASS_THROUGH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

If PassThrough, the topic passes trace headers received from the Amazon SNS publisher to its subscription.
If set to Active, Amazon SNS will vend X-Ray segment data to topic owner account if the sampled flag in the tracing header is true.

The default TracingConfig is `PassThrough`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default TracingConfig is `PassThrough`.
The default TracingConfig is `TracingConfig.PASS_THROUGH`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Copy link
Contributor

@nmussy nmussy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution 👍

Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to a test file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: a7b4e29
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@jun1-t
Copy link
Contributor Author

jun1-t commented Apr 10, 2024

@nmussy

LGTM, thanks for the contribution 👍

Thank you so much for your continued reviews.
However, I accidentally closed this pull request while trying to resolve conflicts.
I have opened a new pull request, could you please review it?
#29783

@nmussy
Copy link
Contributor

nmussy commented Apr 10, 2024

No worries, I'll have a look 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sns: Support for TracingConfig
3 participants