Add the Distribution data type for instrumentation

This is one of a series of CLs adding a new metric type, EventMetric, which
is used for tracking numerical distributions.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132103552
This commit is contained in:
shikhman 2016-09-02 14:23:08 -07:00 committed by Ben McIlwain
parent 180240ae04
commit dcb189943b
13 changed files with 961 additions and 0 deletions

View file

@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
/** Static helper methods for the Metrics library. */
final class MetricsUtils {
private static final Double NEGATIVE_ZERO = -0.0;
private static final String LABEL_SIZE_ERROR =
"The count of labelValues must be equal to the underlying Metric's count of labels.";
@ -45,4 +46,11 @@ final class MetricsUtils {
static void checkLabelValuesLength(Metric<?> metric, ImmutableList<String> labelValues) {
checkArgument(labelValues.size() == metric.getMetricSchema().labels().size(), LABEL_SIZE_ERROR);
}
/** Check that the given double is not infinite, {@code NaN}, or {@code -0.0}. */
static void checkDouble(double value) {
checkArgument(
!Double.isInfinite(value) && !Double.isNaN(value) && !NEGATIVE_ZERO.equals(value),
"value must be finite, not NaN, and not -0.0");
}
}