Class Histogram.Builder
- Enclosing class:
- Histogram
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
classicExponentialUpperBounds
(double start, double factor, int count) Create classic histogram buckets with exponential boundaries.classicLinearUpperBounds
(double start, double width, int count) Create classic histogram buckets with linear bucket boundaries.Use the classic histogram representation only, i.e. don't maintain native histogram buckets.classicUpperBounds
(double... upperBounds) Set the upper bounds for the classic histogram buckets.Default properties for histogram metrics.nativeInitialSchema
(int nativeSchema) The schema is a number in [-4, 8] defining the resolution of the native histogram.nativeMaxNumberOfBuckets
(int nativeMaxBuckets) Limit the number of native buckets.nativeMaxZeroThreshold
(double nativeMaxZeroThreshold) Native histogram buckets get smaller and smaller the closer they get to zero.nativeMinZeroThreshold
(double nativeMinZeroThreshold) Native histogram buckets get smaller and smaller the closer they get to zero.Use the native histogram representation only, i.e. don't maintain classic histogram buckets.nativeResetDuration
(long duration, TimeUnit unit) If the histogram needed to be scaled down becausenativeMaxNumberOfBuckets(int)
was exceeded, reset the histogram after a certain time interval to go back to the originalnativeInitialSchema(int)
.Allow Exemplars for this metric.Turn off Exemplars for this metric.Methods inherited from class MetricWithFixedMetadata.Builder
constLabels, help, labelNames, name, unit
-
Field Details
-
DEFAULT_CLASSIC_UPPER_BOUNDS
-
-
Method Details
-
build
- Specified by:
build
in classMetricWithFixedMetadata.Builder<Histogram.Builder,
Histogram>
-
getDefaultProperties
Default properties for histogram metrics. -
nativeOnly
Use the native histogram representation only, i.e. don't maintain classic histogram buckets. SeeHistogram
for more info. -
classicOnly
Use the classic histogram representation only, i.e. don't maintain native histogram buckets. SeeHistogram
for more info. -
classicUpperBounds
Set the upper bounds for the classic histogram buckets. Default isDEFAULT_CLASSIC_UPPER_BOUNDS
. If the +Inf bucket is missing it will be added. If upperBounds contains duplicates the duplicates will be removed. -
classicLinearUpperBounds
Create classic histogram buckets with linear bucket boundaries.Example:
withClassicLinearBuckets(1.0, 0.5, 10)
creates bucket boundaries[[1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5]
.- Parameters:
start
- is the first bucket boundarywidth
- is the width of each bucketcount
- is the total number of buckets, including start
-
classicExponentialUpperBounds
Create classic histogram buckets with exponential boundaries.Example:
withClassicExponentialBuckets(1.0, 2.0, 10)
creates bucket boundaries[1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0]
- Parameters:
start
- is the first bucket boundaryfactor
- growth factorcount
- total number of buckets, including start
-
nativeInitialSchema
The schema is a number in [-4, 8] defining the resolution of the native histogram. Default isDEFAULT_NATIVE_INITIAL_SCHEMA
.The higher the schema, the finer the resolution. Schema is Prometheus terminology. In OpenTelemetry it's called "scale".
Note that the schema for a histogram may be automatically decreased at runtime if the number of native histogram buckets exceeds
nativeMaxNumberOfBuckets(int)
.The following table shows:
- factor: The growth factor for bucket boundaries, i.e. next bucket boundary = growth factor * previous bucket boundary.
- max quantile error: The maximum error for quantiles calculated using the Prometheus histogram_quantile() function, relative to the observed value, assuming harmonic mean.
max quantile errors for different growth factors schema factor max quantile error -4 65.536 99% -3 256 99% -2 16 88% -1 4 60% 0 2 33% 1 1.4142... 17% 2 1.1892... 9% 3 1.1090... 4% 4 1.0442... 2% 5 1.0218... 1% 6 1.0108... 0.5% 7 1.0054... 0.3% 8 1.0027... 0.1% -
nativeMaxZeroThreshold
Native histogram buckets get smaller and smaller the closer they get to zero. To avoid wasting a lot of buckets for observations fluctuating around zero, we consider all values in [-zeroThreshold, +zeroThreshold] to be equal to zero.The zeroThreshold is initialized with minZeroThreshold, and will grow up to maxZeroThreshold if the number of native histogram buckets exceeds nativeMaxBuckets.
Default is
DEFAULT_NATIVE_MAX_NUMBER_OF_BUCKETS
. -
nativeMinZeroThreshold
Native histogram buckets get smaller and smaller the closer they get to zero. To avoid wasting a lot of buckets for observations fluctuating around zero, we consider all values in [-zeroThreshold, +zeroThreshold] to be equal to zero.The zeroThreshold is initialized with minZeroThreshold, and will grow up to maxZeroThreshold if the number of native histogram buckets exceeds nativeMaxBuckets.
Default is
DEFAULT_NATIVE_MIN_ZERO_THRESHOLD
. -
nativeMaxNumberOfBuckets
Limit the number of native buckets.If the number of native buckets exceeds the maximum, the
nativeInitialSchema(int)
is decreased, i.e. the resolution of the histogram is decreased to reduce the number of buckets.Default is
DEFAULT_NATIVE_MAX_NUMBER_OF_BUCKETS
. -
nativeResetDuration
If the histogram needed to be scaled down becausenativeMaxNumberOfBuckets(int)
was exceeded, reset the histogram after a certain time interval to go back to the originalnativeInitialSchema(int)
.Reset means all values are set to zero. A good value might be 24h or 7d.
Default is no reset.
-
withExemplars
Allow Exemplars for this metric. -
withoutExemplars
Turn off Exemplars for this metric.
-