blob: f47a796948f52574c676b34e2c25dc86f1ac6b84 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
}
}
|