Skip to content

(aws-dynamodb): metricThrottledRequestsForOperation is not part of the ITable interface. #21963

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

Closed
Sunilkby17 opened this issue Sep 8, 2022 · 2 comments · Fixed by #22097
Closed
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1

Comments

@Sunilkby17
Copy link

Describe the bug

ITable interface doesn't contain metricThrottledRequestsForOperation but instead contains deprecated metricThrottledRequests which has an issue and doesn't provide any metrics at all. By just having metricThrottledRequests in ITable interface is hiding the fact that it's deprecated and not allowing the recommended metricThrottledRequestsForOperation to use for users who declare the objects with ITable as type.

Expected Behavior

ITable interface should contain metricThrottledRequestsForOperation declaration

Current Behavior

ITable interface contains metricThrottledRequests declartion which is providing invalid metrics or not providing any metircs at all. So there is a new method (metricThrottledRequestsForOperation) provided as alternative and recommended according to documentation but it's not part of the ITable interface. If an object is declared with ITable type then the recommended method can't be accesed.


  /**
   * How many requests are throttled on this table
   *
   * Default: sum over 5 minutes
   *
   * @deprecated Do not use this function. It returns an invalid metric. Use `metricThrottledRequestsForOperation` instead.
   */
  public metricThrottledRequests(props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return this.metric('ThrottledRequests', { statistic: 'sum', ...props });
  }

  /**
   * How many requests are throttled on this table, for the given operation
   *
   * Default: sum over 5 minutes
   */
  public metricThrottledRequestsForOperation(operation: string, props?: cloudwatch.MetricOptions): cloudwatch.Metric {
    return new cloudwatch.Metric({
      ...DynamoDBMetrics.throttledRequestsSum({ Operation: operation, TableName: this.tableName }),
      ...props,
    }).attachTo(this);
  }

Reproduction Steps

if an object is declared with ITable as type then only getThrottledMetrics can be accessed and not metricThrottledRequestsForOperation

export class DynamoDBTableMetricGenerator {

    private readonly dynamoDbTable: ITable;

    constructor(dynamoDbTable: ITable) {
        this.dynamoDbTable = props.dynamoDbTable;
    }

    /**
     * Returns metircs for throttled requests on the table for all the operations passed
     */
    getThrottledMetrics(operations: strings[], props: MetricOptions): Metric[] {
         operations.forEach((operation) => {
                this.dynamoDbTable.metricThrottledRequests({
                    label: operation,
                    period: Duration.minutes(1),
                    dimensions: {
                        TableName: this.dynamoDbTable.tableName,
                        Operation: operation,
                    },
                }),
            });
        }
    }

Possible Solution

If metricThrottledRequestsForOperation is added to the ITable interface then the object can access it and use accordingly

export class DynamoDBTableMetricGenerator {

    private readonly dynamoDbTable: ITable;

    constructor(dynamoDbTable: ITable) {
        this.dynamoDbTable = props.dynamoDbTable;
    }

    /**
     * Returns metircs for throttled requests on the table for all the operations passed
     */
    getThrottledMetrics(operations: strings[], props: MetricOptions): Metric[] {
         operations.forEach((operation) => {
                this.dynamoDbTable.metricThrottledRequestsForOperation(operation, {
                    label: operation,
                    period: Duration.minutes(1),
                    dimensions: {
                        TableName: this.dynamoDbTable.tableName,
                        Operation: operation,
                    },
                }),
            });
        }
    }

Additional Information/Context

No response

CDK CLI Version

3

Framework Version

No response

Node.js Version

14.x

OS

GNU/Linux

Language

Typescript

Language Version

No response

Other information

No response

@Sunilkby17 Sunilkby17 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 8, 2022
@github-actions github-actions bot added the @aws-cdk/aws-dynamodb Related to Amazon DynamoDB label Sep 8, 2022
@Naumel Naumel added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 8, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1 and removed p2 labels Sep 8, 2022
@VarunWachaspati
Copy link
Contributor

Raised a PR to add the recommended method metricThrottledRequestsForOperation() to the ITable interface.

@mergify mergify bot closed this as completed in #22097 Sep 27, 2022
mergify bot pushed a commit that referenced this issue Sep 27, 2022

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
# Description

This PR is changing `metricThrottledRequestsForOperation` and `metricSystemErrorForOperations` to receive the `OperationsMetricsOptions` parameter to standardize these calls and adds `metricThrottledRequestsForOperation` to the ITable interface

I also change the `metricThrottledRequests` to deprecated

Closes #21963 
----

### 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*
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

arewa pushed a commit to arewa/aws-cdk that referenced this issue Oct 8, 2022
…22097)

# Description

This PR is changing `metricThrottledRequestsForOperation` and `metricSystemErrorForOperations` to receive the `OperationsMetricsOptions` parameter to standardize these calls and adds `metricThrottledRequestsForOperation` to the ITable interface

I also change the `metricThrottledRequests` to deprecated

Closes aws#21963 
----

### 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*
homakk pushed a commit to homakk/aws-cdk that referenced this issue Dec 1, 2022
…22097)

# Description

This PR is changing `metricThrottledRequestsForOperation` and `metricSystemErrorForOperations` to receive the `OperationsMetricsOptions` parameter to standardize these calls and adds `metricThrottledRequestsForOperation` to the ITable interface

I also change the `metricThrottledRequests` to deprecated

Closes aws#21963 
----

### 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p1
Projects
None yet
4 participants