diff options
Diffstat (limited to 'simplemetrics/src/main/java/com/yahoo/metrics/simple/MetricSettings.java')
-rw-r--r-- | simplemetrics/src/main/java/com/yahoo/metrics/simple/MetricSettings.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/simplemetrics/src/main/java/com/yahoo/metrics/simple/MetricSettings.java b/simplemetrics/src/main/java/com/yahoo/metrics/simple/MetricSettings.java new file mode 100644 index 00000000000..f47a796948f --- /dev/null +++ b/simplemetrics/src/main/java/com/yahoo/metrics/simple/MetricSettings.java @@ -0,0 +1,70 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.metrics.simple; + +import com.google.common.annotations.Beta; + +/** + * All information needed for creating any extra data structures associated with + * a single metric, outside of its basic type. + * + * @author steinar + */ +@Beta +public final class MetricSettings { + + /** + * A builder for the immutable MetricSettings instances. + */ + @Beta + public static final class Builder { + private boolean histogram = false; + + /** + * Create a new builder for a MetricSettings instance with default + * settings. + */ + public Builder() { + } + + /** + * Set whether a resulting metric should have a histogram. Default is + * false. + * + * @param histogram + * whether to generate a histogram + * @return this, to facilitate chaining + */ + public Builder histogram(boolean histogram) { + this.histogram = histogram; + return this; + } + + /** + * Build a fresh MetricSettings instance. + * + * @return a MetricSettings instance containing the values set in this + * builder + */ + public MetricSettings build() { + return new MetricSettings(histogram); + } + } + + private final int significantDigits; // could have been static, but would + // just introduce bugs when we must + // expose this setting + private final boolean histogram; + + private MetricSettings(boolean histogram) { + this.histogram = histogram; + this.significantDigits = 2; + } + + int getSignificantdigits() { + return significantDigits; + } + + boolean isHistogram() { + return histogram; + } +} |