-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
There was a problem hiding this 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. |
There was a problem hiding this comment.
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
* @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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed to enum.
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}".`); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
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"./); | ||
}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
Did you forget to push your latest commits? |
Failed build after code fix. |
There was a problem hiding this 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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PASSTHROUGH = 'PassThrough', | |
PASS_THROUGH = 'PassThrough', |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @default PassThrough | |
* @default TracingConfig.PASS_THROUGH |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default TracingConfig is `PassThrough`. | |
The default TracingConfig is `TracingConfig.PASS_THROUGH`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this 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 👍
b6dd635
to
a7b4e29
Compare
There was a problem hiding this 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.
The pull request linter fails with the following errors:
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 |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
No worries, I'll have a look 👍 |
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