-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(cloudwatch): CompositeAlarm #8498
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.
Haven't had a look in detail, will do that Soon(tm) (promise), but first impressions.
I really like where this is going, with some caveats:
alarm1.toAlarmRule(AlarmState.ALARM)
: I'd prefer it if you could just writealarm1
here (compound ALARM states seem like they will be the 99% case of uses, why not optimize for it?)
You can do this by making IAlarm
extend IAlarmRule
.
new OrAlarmRule(), new AndAlarmRule()
: technically, yeah, of course. But I think I'd prefer more discoverable static factory functions instead (friendlier to autocomplete).
Spitballing some alternative syntax here:
new CompositeAlarm(this, 'ComplicatedAlarmCondition', {
alarmRule: AlarmRule.someOf(
AlarmRule.allOf(
alarm1,
AlarmRule.fromAlarm(alarm2, AlarmState.OK),
alarm3),
AlarmRule.not(AlarmRule.fromAlarm(alarm4, AlarmState.INSUFFICIENT_DATA)),
AlarmRule.fromBoolean(false),
),
});
What do you think?
Not entirely sure I'm in love with the AlarmRule.fromAlarm(alarm, STATE)
either, but at least it's consistent. I can see the following alternatives:
1. alarm.toAlarmRule(AlarmState.OK)
2. AlarmRule.fromAlarm(alarm, AlarmState.OK)
3. AlarmRule.fromAlarmOk(alarm)
Probably also |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
i completely agree, i was unhappy about how that looked too. this is unnecessary verbosity. i think having Alarm implement the IAlarmRule interface will get the necessary brevity. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -99,7 +99,8 @@ | |||
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.color", | |||
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.label", | |||
"props-default-doc:@aws-cdk/aws-cloudwatch.MetricRenderingProperties.stat", | |||
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricExpressionConfig.period" | |||
"duration-prop-type:@aws-cdk/aws-cloudwatch.MetricExpressionConfig.period", | |||
"resource-attribute:@aws-cdk/aws-cloudwatch.CompositeAlarm.compositeAlarmArn" |
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.
Why not just solve the issue by putting @attribute
in the docstring?
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.
i tried, it didn't seem to work. it continued to complain about the missing attribute.
You closed a bunch of comments but I don't see a new revision. Missing push? :) |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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 master 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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license