Class Histogram.Builder
- Enclosing class:
- Histogram
-
Field Summary
FieldsFields inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata.Builder
name
Fields inherited from class io.prometheus.metrics.core.metrics.Metric.Builder
illegalLabelNames, properties
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Use the classic histogram representation only, i.e.io.prometheus.metrics.config.MetricsProperties
Default properties for histogram metrics.Use the native histogram representation only, i.e.protected Histogram.Builder
self()
protected io.prometheus.metrics.config.MetricsProperties
Override if there are more properties than just exemplars enabled.withClassicBuckets
(double... upperBounds) Set the upper bounds for the classic histogram buckets.withClassicExponentialBuckets
(double start, double factor, int count) Create classic histogram bucxkets with exponential boundaries.withClassicLinearBuckets
(double start, double width, int count) Create classic histogram buckets with linear bucket boundaries.withNativeInitialSchema
(int nativeSchema) The schema is a number in [-4, 8] defining the resolution of the native histogram.withNativeMaxNumberOfBuckets
(int nativeMaxBuckets) Limit the number of native buckets.withNativeMaxZeroThreshold
(double nativeMaxZeroThreshold) Native histogram buckets get smaller and smaller the closer they get to zero.withNativeMinZeroThreshold
(double nativeMinZeroThreshold) Native histogram buckets get smaller and smaller the closer they get to zero.withNativeResetDuration
(long duration, TimeUnit unit) If the histogram needed to be scaled down becausewithNativeMaxNumberOfBuckets(int)
was exceeded, reset the histogram after a certain time interval to go back to the originalwithNativeInitialSchema(int)
.Methods inherited from class io.prometheus.metrics.core.metrics.MetricWithFixedMetadata.Builder
withHelp, withLabelNames, withName, withUnit
Methods inherited from class io.prometheus.metrics.core.metrics.Metric.Builder
register, register, withConstLabels
-
Field Details
-
DEFAULT_CLASSIC_UPPER_BOUNDS
-
exemplarsEnabled
-
-
Method Details
-
build
- Specified by:
build
in classMetricWithFixedMetadata.Builder<Histogram.Builder,
Histogram>
-
toProperties
Override if there are more properties than just exemplars enabled. -
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. -
withClassicBuckets
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. -
withClassicLinearBuckets
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
-
withClassicExponentialBuckets
Create classic histogram bucxkets with exponential boundaries.Example:
withClassicExponentialBuckets(1.0, 2.0, 10)
creates bucket bounaries[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
-
withNativeInitialSchema
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
withNativeMaxNumberOfBuckets(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% -
withNativeMaxZeroThreshold
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
. -
withNativeMinZeroThreshold
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
. -
withNativeMaxNumberOfBuckets
Limit the number of native buckets.If the number of native buckets exceeds the maximum, the
withNativeInitialSchema(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
. -
withNativeResetDuration
If the histogram needed to be scaled down becausewithNativeMaxNumberOfBuckets(int)
was exceeded, reset the histogram after a certain time interval to go back to the originalwithNativeInitialSchema(int)
.Reset means all values are set to zero. A good value might be 24h or 7d.
Default is no reset.
-
self
- Specified by:
self
in classMetricWithFixedMetadata.Builder<Histogram.Builder,
Histogram>
-
withExemplars
-
withoutExemplars
-