Skip to content

Calculate metrics using buckets. #18

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 1 commit into from
Jan 8, 2018

Conversation

steven-aerts
Copy link
Contributor

Rewrite the metrics calculation. It replaces the window array which
a data sample for every operation with a fixed size list of buckets.
This resolves #17 which describes this memory leak.

Rewrite the metrics calculation.  It replaces the window array which
a data sample for every operation with a fixed size list of buckets.
This resolves vert-x3#17 which describes this memory leak.
@vietj vietj added the to review label Jan 4, 2018
Copy link
Contributor Author

@steven-aerts steven-aerts left a comment

Choose a reason for hiding this comment

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

I added some comments on some small implementation choices I made.

Hope you like it.

}

public void add(Operation operation) {
getBucket(operation.end).add(operation);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the original implementation, one looked at the begin timestamps:

window.removeIf(operation -> operation.begin < beginningOfTheWindow);

This causes operations which take more than 10 seconds to not being taken into account in the rolling statistics. So that is why I decided to look at .end.


private Summary(long bucketIndex) {
this.bucketIndex = bucketIndex;
statistics = new Histogram(2);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Propose to use 2 significant digits to use less space. (4 kilobyte/histogram <> 64kilobyte per histogram)

No problem for me to change it back to 3.

} else {
json.put("rollingSuccessPercentage", ((double) rollingSuccess / window.size()) * 100);
json.put("rollingErrorPercentage",
((double) (rollingException + rollingFailure + rollingTimeout + rollingShortCircuited) / window.size()) * 100);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shortCircuits were only seen as errors for for the rollingErrorPercentage, not for the totalErrorPercentage.

Removed it for consistency. But do not mind to regard them as errors.

@cescoffier
Copy link
Member

It looks great. Can you add a test to check it. Also, I believe you did, but did you try with the Hystrix dashboard?

@cescoffier cescoffier self-requested a review January 8, 2018 06:59
@cescoffier cescoffier added this to the 3.5.1 milestone Jan 8, 2018
@cescoffier cescoffier added the bug label Jan 8, 2018
@steven-aerts
Copy link
Contributor Author

@cescoffier thanks for your review.

I validated it with the Hystrix dashboard.

There are already some extensive tests on the CircuitBreakerMetrics, which all pass unadapted after my change, I will take a look which cases are not covered by them and extend.

@cescoffier
Copy link
Member

Great, thanks!

@cescoffier cescoffier merged commit 31551aa into vert-x3:master Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Circuit breaker leaks CircuitBreakerMetrics$Operation objects
3 participants