-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(elbv2): add metrics to INetworkTargetGroup and IApplicationTargetGroup #23993
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.
d03fec0
to
6f8932e
Compare
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
0e9e3a5
to
5f9d157
Compare
This PR contains the commit from #23972, so that PR needs to be merged first. |
2026066
to
c240333
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.
minor style comment, but other than that looks ready to merge!
packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/target-group.test.ts
Outdated
Show resolved
Hide resolved
b6bfeae
to
aa30419
Compare
Pull request has been modified.
aa30419
to
c3341b4
Compare
…tGroup By moving the metrics methods to the `INetworkTargetGroup` and `IApplicationTargetGroup` interfaces it allows to create these metrics also for Target Groups that are imported via the `fromTargetGroupAttributes()` method. To create the metrics for Target Groups requires (1) the full name of the Target Group and (2) the full name of the Load Balancer. For (1): it is readily available given that all imported Target Groups need to provide its ARN. For (2), it is an optional value, so the `.metrics` parameter will throw an error if it was not provided. To solve this problem I did: - Introduce a new interface for each TG type: `INetworkTargetGroupMetrics`, `IApplicationTargetGroupMetrics` - Create a concrete implementation for the new interfaces (1 for each): `NetworkTargetGroupMetrics` and `ApplicationTargetGroupMetrics` - Make each concrete implementation of each Load Balancer to also provide a `metrics` field. The concrete implementations of the load balancers are: `ImportedApplicationTargetGroup`, and `ApplicationLoadBalancer` (and the same for the NLB classes). I chose to create a new interface because code can be reused across the 3 concrete implementations of each Load Balancer. I deprecated the `metricXXX()` methods of each load balancer because I think it is cleaner to access metrics through the new `metrics` attribute/interface. There is a small **gotcha** here because the parameter of the `fromTargetGroupAttributes()` method that refers to the LB is: `loadBalancerArns`, which has its documentation as: > A Token representing the list of ARNs for the load balancer routing to this target group I'm not treating this parameter as a collection of ARNs, but as a single AR. Also, I'm not treating it only as a token, but hardcoded ARNs can also be supplied, which "sort of" violates its interface. This attribute is weird though because Target Groups cannot have multiple Load Balancers as of today, although its documentation doesn't clearly express that is the case. fix: aws#10850 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-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)? * [x] 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*
c3341b4
to
9c3fecd
Compare
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). |
Pull request has been modified.
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). |
This PR follows the same conventions as #23853
By moving the metrics methods to the
INetworkTargetGroup
andIApplicationTargetGroup
interfaces it allows to create these metrics also for Target Groups that are imported via thefromTargetGroupAttributes()
method.To create the metrics for Target Groups requires (1) the full name of the Target Group and (2) the full name of the Load Balancer.
For (1): it is readily available given that all imported Target Groups need to provide its ARN.
For (2), it is an optional value, so the
.metrics
parameter will throw an error if it was not provided.To solve this problem I did:
INetworkTargetGroupMetrics
,IApplicationTargetGroupMetrics
NetworkTargetGroupMetrics
andApplicationTargetGroupMetrics
metrics
field. The concrete implementations of the load balancers are:ImportedApplicationTargetGroup
, andApplicationLoadBalancer
(and the same for the NLB classes).I chose to create a new interface because code can be reused across the 3 concrete implementations of each Load Balancer. I deprecated the
metricXXX()
methods of each load balancer because I think it is cleaner to access metrics through the newmetrics
attribute/interface.There is a small gotcha here because the parameter of the
fromTargetGroupAttributes()
method that refers to the LB is:loadBalancerArns
, which has its documentation as:I'm not treating this parameter as a collection of ARNs, but as a single ARN. Also, I'm not treating it only as a token, but hardcoded ARNs can also be supplied, which "sort of" violates its interface. This attribute is weird though because Target Groups cannot have multiple Load Balancers as of today, although its documentation doesn't clearly express that is the case.
fix: #10850
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license