-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-12755] Stop throwing exceptions during formatting and calculation of a percentile #15329
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,15 +142,8 @@ public synchronized long getTotalCount() { | |
|
|
||
| public synchronized String getPercentileString(String elemType, String unit) { | ||
| return String.format( | ||
| "Total number of %s: %s, P99: %s%s, P90: %s%s, P50: %s%s", | ||
| elemType, | ||
| getTotalCount(), | ||
| DoubleMath.roundToInt(p99(), RoundingMode.HALF_UP), | ||
| unit, | ||
| DoubleMath.roundToInt(p90(), RoundingMode.HALF_UP), | ||
| unit, | ||
| DoubleMath.roundToInt(p50(), RoundingMode.HALF_UP), | ||
| unit); | ||
| "Total number of %s: %s, P99: %.0f %s, P90: %.0f %s, P50: %.0f %s", | ||
| elemType, getTotalCount(), p99(), unit, p90(), unit, p50(), unit); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -196,7 +189,7 @@ public double p50() { | |
| private synchronized double getLinearInterpolation(double percentile) { | ||
| long totalNumOfRecords = getTotalCount(); | ||
| if (totalNumOfRecords == 0) { | ||
| throw new RuntimeException("histogram has no record."); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious. Did you decide to make this change because you saw this exception thrown in a user pipeline? (Its possible the code is designed to not invoke this method in this case). Just wondering if actual pipelines are hitting this? Or did you just decide to make this change to make to remove the exception, make the code safer, etc.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User pipelines were hitting this, b/189940287 |
||
| return Double.NaN; | ||
| } | ||
| int index; | ||
| double recordSum = numBottomRecords; | ||
|
|
@@ -245,10 +238,11 @@ public abstract static class LinearBuckets implements BucketType { | |
|
|
||
| public static LinearBuckets of(double start, double width, int numBuckets) { | ||
| if (width <= 0) { | ||
| throw new RuntimeException(String.format("width should be greater than zero: %f", width)); | ||
| throw new IllegalArgumentException( | ||
| String.format("width should be greater than zero: %f", width)); | ||
| } | ||
| if (numBuckets <= 0) { | ||
| throw new RuntimeException( | ||
| throw new IllegalArgumentException( | ||
| String.format("numBuckets should be greater than zero: %d", numBuckets)); | ||
| } | ||
| return new AutoValue_HistogramData_LinearBuckets(start, width, numBuckets); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this code shouldn't ever be called if totalNumOfRecords == 0
This feature is only used to print some info logging.
So ti could just print something else in this case
WDYT @ihji ?