Skip to content
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

fix(dynamodb): Misconfigured metrics causing empty graphs #11283

Merged
merged 31 commits into from
Nov 6, 2020

Conversation

iliapolo
Copy link
Contributor

@iliapolo iliapolo commented Nov 4, 2020

This PR corrects 3 misconfigured metrics we had on the Table construct.

UserErrors

Per the documentation The table.metricUserErrors() does not emit the TableName dimension. It is actually an account (and region) wide metric.

The fix was to just validate that no dimensions are passed to this operation.

SystemErrors

Per the documentation The table.metricSystemErrors() is always emitted with the Operation dimension, and our current implementation does not pass it.

The fix adds an additional operations property to the method, that allows passing an array of operations, the returned metric will be a SUM over those operations. If no operation is passed, we sum all available operations.

Since the current method returns a Metric, returning a math expression won't work since it is an IMetric that doesn't extend Metric. To avoid breaking changes, we introduce a new method, metricSystemErrorsForOperations:

const totalSystemErrors = table.metricSystemErrorsForOperations();

const getPutSystemErrors = table.metricSystemErrorsForOperations({ 
  operations: [dynamo.Operation.PUT_ITEM, dynamo.Operation.GET_ITEM]
}); 

SuccessfulRequestLatency

Per the documentation The table.metricSuccessfulRequestLatency() is always emitted with the Operation dimension, and our current implementation does not pass it.

The fix requires user to pass the Operation dimension.

So the API is:

const getLatency = table.metricSuccessfulRequestLatency({ 
  dimensions: {
    Operation: 'GetItem'
  },
});

Fixes #11261
Fixes #11269


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Nov 4, 2020

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 4, 2020
@iliapolo iliapolo requested a review from a team November 4, 2020 13:50
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I think we need to do a "deprecate + create new methods" pattern here, over breaking changes to a stable module. There are users for whom the API wasn't broken, who will hit compilation issues when updating to this solution.

That's likely going to lead to some awkward method naming, but I don't see how we get around that otherwise.

packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
@iliapolo iliapolo requested a review from njlynch November 5, 2020 12:41
@iliapolo
Copy link
Contributor Author

iliapolo commented Nov 5, 2020

Just for fun, here is how a combined latency graph will look like:

Screen Shot 2020-11-05 at 2 42 37 PM

Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. A buncha nit-picky stuff. Needs to be marked as ready for review + merge from master so you can fix the build failures.

packages/@aws-cdk/aws-cloudwatch/test/test.alarm.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-cloudwatch/lib/alarm.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
@iliapolo iliapolo requested a review from rix0rrr November 5, 2020 16:20
@iliapolo iliapolo marked this pull request as ready for review November 5, 2020 17:08
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Nov 5, 2020
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things to think about for your consideration. Won't block the PR on it, but do be sure you're satisfied with your own choices before merging :).

packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Show resolved Hide resolved
packages/@aws-cdk/aws-dynamodb/lib/table.ts Outdated Show resolved Hide resolved
@skinny85 skinny85 assigned iliapolo and unassigned skinny85 Nov 5, 2020
@iliapolo iliapolo changed the title fix(dynamodb): Some metrics are misconfigured fix(dynamodb): Misconfigured metrics causing empty graphs Nov 5, 2020
@iliapolo iliapolo removed the pr/do-not-merge This PR should not be merged at this time. label Nov 5, 2020
@mergify
Copy link
Contributor

mergify bot commented Nov 5, 2020

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b24f7d1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Nov 6, 2020

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).

@mergify mergify bot merged commit 9968669 into master Nov 6, 2020
@mergify mergify bot deleted the epolon/dynamodb-metrics branch November 6, 2020 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
5 participants