Skip to content

Fixed a bug of carrying default dimensions over flushes #75

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

Merged
merged 2 commits into from
Apr 28, 2021

Conversation

yaozhaoy
Copy link
Contributor

@yaozhaoy yaozhaoy commented Apr 28, 2021

Issue #, if available:
#37

Description of changes:
Fixed a bug that the default dimensions are carried over to new log event after calling setDimension

Before change, with the following code

        MetricsLogger logger = new MetricsLogger(envProvider);

        logger.setDimensions();
        logger.putMetric("Counter", 1.0);
        logger.flush();

        logger.putMetric("Counter", 2.0);
        // second flush
        logger.flush();

There're still default dimensions included in the log event from second flush.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@yaozhaoy yaozhaoy requested a review from jaredcnance April 28, 2021 00:54
@@ -70,6 +70,11 @@ MetricDirective createMetricDirective() {
return newMetricDirective;
}

void setMetricDirective(MetricDirective metricDirective) {
cloudWatchMetrics = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

new ArrayList<>(1) or Collections.singletonList(...) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, I'll leave this as is for now. For now, we only expect to have one element in this list. But this may change in the future.

@yaozhaoy yaozhaoy merged commit da5a3b1 into awslabs:master Apr 28, 2021
@yaozhaoy yaozhaoy deleted the fix_bug_preserve_dimension branch April 28, 2021 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants