From 0fdde1cc9eb920b7470d1355428000eef1760cd6 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Tue, 6 Jun 2017 14:27:04 -0700 Subject: [PATCH] Change FibonacciFitter to just be a utility method It turns out that StackdriverWriter uses reflection on the class of the DistributionFitter instance, so rather than giving it custom handling for FibonacciFitters, it's easier to turn FibonacciFitter into a single utility method that takes advantage of existing support for CustomFitters. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158190147 --- .../monitoring/metrics/FibonacciFitter.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/java/google/registry/monitoring/metrics/FibonacciFitter.java b/java/google/registry/monitoring/metrics/FibonacciFitter.java index c03a2cdc6..f7d6a36ab 100644 --- a/java/google/registry/monitoring/metrics/FibonacciFitter.java +++ b/java/google/registry/monitoring/metrics/FibonacciFitter.java @@ -16,11 +16,10 @@ package google.registry.monitoring.metrics; import static com.google.common.base.Preconditions.checkArgument; -import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableSortedSet; /** - * A {@link DistributionFitter} with intervals of increasing size using the Fibonacci sequence. + * Utility method to create a {@link CustomFitter} with intervals using the Fibonacci sequence. * *

A Fibonacci fitter is useful in situations where you want more precision on the low end than * an {@link ExponentialFitter} with exponent base 2 would provide without the hassle of dealing @@ -31,17 +30,16 @@ import com.google.common.collect.ImmutableSortedSet; *

The interval boundaries are chosen as {@code (-inf, 0), [0, 1), [1, 2), [2, 3), [3, 5), [5, * 8), [8, 13)}, etc., up to {@code [fibonacciFloor(maxBucketSize), inf)}. */ -@AutoValue -public abstract class FibonacciFitter implements DistributionFitter { +public final class FibonacciFitter { /** - * Returns a new {@link FibonacciFitter}. + * Returns a new {@link CustomFitter} with bounds corresponding to the Fibonacci sequence. * * @param maxBucketSize the maximum bucket size to create (rounded down to the nearest Fibonacci * number) * @throws IllegalArgumentException if {@code maxBucketSize <= 0} */ - public static FibonacciFitter create(long maxBucketSize) { + public static CustomFitter create(long maxBucketSize) { checkArgument(maxBucketSize > 0, "maxBucketSize must be greater than 0"); ImmutableSortedSet.Builder boundaries = ImmutableSortedSet.naturalOrder(); @@ -56,9 +54,8 @@ public abstract class FibonacciFitter implements DistributionFitter { k = i + j; } - return new AutoValue_FibonacciFitter(boundaries.build()); + return CustomFitter.create(boundaries.build()); } - @Override - public abstract ImmutableSortedSet boundaries(); + private FibonacciFitter() {} }