Skip to content

Disallow duplicate dimension sets. #20

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
jaredcnance opened this issue Feb 22, 2020 · 0 comments · Fixed by #21 or #104
Closed

Disallow duplicate dimension sets. #20

jaredcnance opened this issue Feb 22, 2020 · 0 comments · Fixed by #21 or #104

Comments

@jaredcnance
Copy link
Member

jaredcnance commented Feb 22, 2020

There is no need for duplicate dimension sets like the following.

{
  "Dimensions": [
    [ "A", "B"],
    [ "A", "B"],
    [ "B", "A"],
  ]
}

This would re-create the same metric 3 times and is equivalent to:

{
  "Dimensions": [ [ "A", "B"] ]
}

This is needed for #14. It allows for things like the following while also allowing for re-use of the logger instance.

const doWork = metricScope(metrics => () => {
  metrics.putDimensions(dimensions);
  // ...
});

// act
doWork();
doWork();
logger.putMetric(metricKey, 0);
await logger.flush();

logger.putMetric(metricKey, 1);
await logger.flush();
jaredcnance added a commit that referenced this issue Feb 22, 2020
jaredcnance added a commit that referenced this issue Feb 22, 2020
- disallow duplicate dimensions sets
- fix integ tests
- move helper methods to bottom of file for readability
- change expected samples to 3

Closes #20
aaronlna pushed a commit to aaronlna/aws-embedded-metrics-java that referenced this issue Nov 22, 2021
This is a Java-equivalent bug-fix for the Node issue:
awslabs/aws-embedded-metrics-node#20

New conditions check for any matching dimension set before
skipping put dimensions-- to prevent duplicates from being stored.

[TESTING]

Unit test updated to address edge case;
multiple dimension sets added and checked for no duplicates.

Ran integration tests using Docker and compared results in CloudWatch.
aaronlna pushed a commit to aaronlna/aws-embedded-metrics-java that referenced this issue Nov 22, 2021
This is the Java-equivalent bug-fix for prior issue in Node:
awslabs/aws-embedded-metrics-node#20

New conditions check for any matching dimension set before
skipping put dimensions. This prevents duplicates from being stored.

[TESTING]

Unit test updated to address edge case;
multiple dimension sets of variable sizes are added and checked.

Ran integration tests using Docker and compared results in CloudWatch.
aaronlna pushed a commit to aaronlna/aws-embedded-metrics-java that referenced this issue Nov 22, 2021
This is the Java-equivalent bug-fix for prior issue in Node:
awslabs/aws-embedded-metrics-node#20

New conditions check for any matching dimension set before
skipping put dimensions. This prevents duplicates from being stored.

[TESTING]

Unit test updated to address edge case;
multiple dimension sets of variable size are added and checked.

Ran integration tests using Docker and compared results in CloudWatch.
aaronlna pushed a commit to aaronlna/aws-embedded-metrics-java that referenced this issue Nov 22, 2021
This is the Java-equivalent bug-fix for prior issue in Node:
awslabs/aws-embedded-metrics-node#20

New conditions check for any matching dimension set before
skipping put dimensions. This prevents duplicates from being stored.

[TESTING]

Unit test updated to address edge case;
multiple dimension sets of variable size are added and checked.

Ran integration tests using Docker and compared results in CloudWatch.
@markkuhn markkuhn linked a pull request Aug 11, 2022 that will close this issue
markkuhn added a commit to awslabs/aws-embedded-metrics-java that referenced this issue Aug 15, 2022
* fix: prevent putDimensions from storing duplicate dimensions

This is the Java-equivalent bug-fix for prior issue in Node:
awslabs/aws-embedded-metrics-node#20

New conditions check for any matching dimension set before
skipping put dimensions. This prevents duplicates from being stored.

[TESTING]

Unit test updated to address edge case;
multiple dimension sets of variable size are added and checked.

Ran integration tests using Docker and compared results in CloudWatch.

* fix: change putDimensions to update/sort existing dimension sets when duplicate

This change ensures new dimension key-values are used for the EMF root node
by removing duplicate dimension sets and adding input dimension set to the
end of the collection.

Example:

```
[
  { "keyA": "value1" },
  { "keyA": "value2" },
]

// expected target member: { "keyA": "value2" }
```

[TESTING]

Updated unit tests to check for this case wherein putDimensions
may be triggered using various dimension set lengths, values, and order.

* Update src/test/java/software/amazon/cloudwatchlogs/emf/model/MetricDirectiveTest.java

* Update src/test/java/software/amazon/cloudwatchlogs/emf/model/MetricDirectiveTest.java

Co-authored-by: Aaron Michael Lamb <[email protected]>
Co-authored-by: Mark Kuhn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant