-
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(aws-cloudwatch): add missing cloudwatch statistics in exported enum (p
, tm
, iqm
, wm
, tc
, ts
)
#23074
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.
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.
Don't think that's needed for this change. |
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
The `Statistic` enum type was incorrectly publicly exposed (it should only have been visible internally to the package), and was enhanced in PR #23074 to have more enum values such as `P10`, `P50`, `P99_9`, etc. The stringification of this `Statistic` type would only have worked in TypeScript anyway (in JSII languages like Java and Python we cannot rely on the string values of enums), and the fact that enums cannot be parameterized made it so that we used to have a lot of redundant enum values. Introduce a new factory class, `Stats`, whose sole purpose is to produce formatted strings to use as CloudWatch `statistic` values, and advertise the use of this class. (We probably shouldn't have been using `string` as the type in the first place, but given that we are factories to produce them seems to be the next best thing).
The `Statistic` enum type was incorrectly publicly exposed (it should only have been visible internally to the package), and was enhanced in PR #23074 to have more enum values such as `P10`, `P50`, `P99_9`, etc. The stringification of this `Statistic` type would only have worked in TypeScript anyway (in JSII languages like Java and Python we cannot rely on the string values of enums), and the fact that enums cannot be parameterized made it so that we used to have a lot of redundant enum values. Deprecate the `Statistic` type, and introduce a new factory class, `Stats`, whose sole purpose is to produce formatted strings to use as CloudWatch `statistic` values, and advertise the use of this class. (We probably shouldn't have been using `string` as the type in the first place, but given that we are factories to produce them seems to be the next best thing). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The `Statistic` enum type was incorrectly publicly exposed (it should only have been visible internally to the package), and was enhanced in PR aws#23074 to have more enum values such as `P10`, `P50`, `P99_9`, etc. The stringification of this `Statistic` type would only have worked in TypeScript anyway (in JSII languages like Java and Python we cannot rely on the string values of enums), and the fact that enums cannot be parameterized made it so that we used to have a lot of redundant enum values. Deprecate the `Statistic` type, and introduce a new factory class, `Stats`, whose sole purpose is to produce formatted strings to use as CloudWatch `statistic` values, and advertise the use of this class. (We probably shouldn't have been using `string` as the type in the first place, but given that we are factories to produce them seems to be the next best thing). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The `Statistic` enum type was incorrectly publicly exposed (it should only have been visible internally to the package), and was enhanced in PR aws#23074 to have more enum values such as `P10`, `P50`, `P99_9`, etc. The stringification of this `Statistic` type would only have worked in TypeScript anyway (in JSII languages like Java and Python we cannot rely on the string values of enums), and the fact that enums cannot be parameterized made it so that we used to have a lot of redundant enum values. Deprecate the `Statistic` type, and introduce a new factory class, `Stats`, whose sole purpose is to produce formatted strings to use as CloudWatch `statistic` values, and advertise the use of this class. (We probably shouldn't have been using `string` as the type in the first place, but given that we are factories to produce them seems to be the next best thing). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
#23095) ### Description Previous PR added support for missing statistics #23074 This PR implements a proper parsing of all these statistics. - Support "short" format `ts99` - Support "long" format - `TS(10%:90%)` | `TS(10:90)` - `TS(:90)` | `TS(:90%)` - `TS(10:)` | `TS(10%:)` - Formats are case insensitive (no breaking changes) - If "long" format and only upper boundary% `TS(:90%)`, can be translated to "short" format `ts90` (`stat.asSingleStatStr`) ### Note I noticed that the following code expected the parsing to throw if it failed, but it actually will **not** fail in any case (it just return `GenericStatistic` if no format matched). I will **not** change this behavior here as I'm not willing to spend more effort testing if this breaks stuff elsewhere. https://github.com/aws/aws-cdk/blob/47943d206c8ff28923e19028acd5991d8e387ac9/packages/%40aws-cdk/aws-cloudwatch/lib/metric.ts#L295-L296 ### Followup work As is, this PR does not change any customer-facing logic. To make use of it, make the parsing throw if no format is recognized. At the end of the parser function, just replace ```ts return { type: 'generic', statistic: stat, } as GenericStatistic; ``` with ```ts throw new UnrecognizedStatisticFormatError() ``` --- You can see all tested inputs here: https://regexr.com/7351s ![2022-11-24_15-52-57](https://user-images.githubusercontent.com/26366184/204067982-05b7bd4f-1c56-4466-8c97-c626e8ac31b2.png) ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
The `Statistic` enum type was incorrectly publicly exposed (it should only have been visible internally to the package), and was enhanced in PR aws#23074 to have more enum values such as `P10`, `P50`, `P99_9`, etc. The stringification of this `Statistic` type would only have worked in TypeScript anyway (in JSII languages like Java and Python we cannot rely on the string values of enums), and the fact that enums cannot be parameterized made it so that we used to have a lot of redundant enum values. Deprecate the `Statistic` type, and introduce a new factory class, `Stats`, whose sole purpose is to produce formatted strings to use as CloudWatch `statistic` values, and advertise the use of this class. (We probably shouldn't have been using `string` as the type in the first place, but given that we are factories to produce them seems to be the next best thing). ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Some statistics were missing from the lib
p
,tm
,iqm
,wm
,tc
,ts
.I added the most common ones in the exported enum, with a good documentation pulled from AWS CloudWatch documentation - Statistics definitions
Fixes #21666 #14688
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license