Class HistogramSnapshot.HistogramDataPointSnapshot
java.lang.Object
io.prometheus.metrics.model.snapshots.DataPointSnapshot
io.prometheus.metrics.model.snapshots.DistributionDataPointSnapshot
io.prometheus.metrics.model.snapshots.HistogramSnapshot.HistogramDataPointSnapshot
- Enclosing class:
HistogramSnapshot
public static final class HistogramSnapshot.HistogramDataPointSnapshot
extends DistributionDataPointSnapshot
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassicHistogramBucketsprivate final NativeHistogramBucketsprivate final NativeHistogramBucketsprivate final intprivate final longprivate final double -
Constructor Summary
ConstructorsModifierConstructorDescriptionHistogramDataPointSnapshot(int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for native histograms (as opposed to classic histograms).HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for classic histograms (as opposed to native histograms).privateHistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis, long scrapeTimestampMillis, long count, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, long nativeZeroCount, double nativeZeroThreshold, boolean internal) HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for a histogram with both, classic and native data.HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis, long scrapeTimestampMillis) Constructor with an additional scrape timestamp. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()private static longcalculateClassicCount(ClassicHistogramBuckets classicBuckets) private static longcalculateCount(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues) private static longcalculateNativeCount(long nativeZeroCount, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues) (package private) DataPointSnapshotescape(EscapingScheme escapingScheme) Will return garbage ifhasClassicHistogramData()isfalse.Will return garbage ifhasNativeHistogramData()isfalse.Will return garbage ifhasNativeHistogramData()isfalse.intThe schema defines the scale of the native histogram, i.g.longNumber of observed zero values.doubleAll observations in [-nativeZeroThreshold; +nativeZeroThreshold] are treated as zero.booleanbooleanprivate voidvalidate()Methods inherited from class DistributionDataPointSnapshot
getCount, getExemplars, getSum, hasCount, hasSumMethods inherited from class DataPointSnapshot
getCreatedTimestampMillis, getLabels, getScrapeTimestampMillis, hasCreatedTimestamp, hasScrapeTimestamp
-
Field Details
-
classicBuckets
-
nativeSchema
private final int nativeSchema -
nativeZeroCount
private final long nativeZeroCount -
nativeZeroThreshold
private final double nativeZeroThreshold -
nativeBucketsForPositiveValues
-
nativeBucketsForNegativeValues
-
-
Constructor Details
-
HistogramDataPointSnapshot
public HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for classic histograms (as opposed to native histograms).To create a new
HistogramSnapshot.HistogramDataPointSnapshot, you can either call the constructor directly or use the Builder withHistogramSnapshot.builder().- Parameters:
classicBuckets- required. Must not be empty. Must at least contain the +Inf bucket.sum- sum of all observed values. Optional, passDouble.NaNif not available.labels- must not be null. UseLabels.EMPTYif there are no labels.exemplars- must not be null. UseExemplars.EMPTYif there are no Exemplars.createdTimestampMillis- timestamp (as inSystem.currentTimeMillis()) when the time series (this specific set of labels) was created (or reset to zero). It's optional. Use0Lif there is no created timestamp.
-
HistogramDataPointSnapshot
public HistogramDataPointSnapshot(int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for native histograms (as opposed to classic histograms).To create a new
HistogramSnapshot.HistogramDataPointSnapshot, you can either call the constructor directly or use the Builder withHistogramSnapshot.builder().- Parameters:
nativeSchema- number in [-4, 8]. See Prometheus client_model metrics.proto.nativeZeroCount- number of observed zero values (zero is special because there is no histogram bucket for zero values).nativeZeroThreshold- observations in [-zeroThreshold, +zeroThreshold] are treated as zero. This is to avoid creating a large number of buckets if observations fluctuate around zero.nativeBucketsForPositiveValues- must not benull. UseNativeHistogramBuckets.EMPTYif empty.nativeBucketsForNegativeValues- must not benull. UseNativeHistogramBuckets.EMPTYif empty.sum- sum of all observed values. Optional, useDouble.NaNif not available.labels- must not be null. UseLabels.EMPTYif there are no labels.exemplars- must not be null. UseExemplars.EMPTYif there are no Exemplars.createdTimestampMillis- timestamp (as inSystem.currentTimeMillis()) when the time series (this specific set of labels) was created (or reset to zero). It's optional. Use0Lif there is no created timestamp.
-
HistogramDataPointSnapshot
public HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis) Constructor for a histogram with both, classic and native data.To create a new
HistogramSnapshot.HistogramDataPointSnapshot, you can either call the constructor directly or use the Builder withHistogramSnapshot.builder().- Parameters:
classicBuckets- required. Must not be empty. Must at least contain the +Inf bucket.nativeSchema- number in [-4, 8]. See Prometheus client_model metrics.proto.nativeZeroCount- number of observed zero values (zero is special because there is no histogram bucket for zero values).nativeZeroThreshold- observations in [-zeroThreshold, +zeroThreshold] are treated as zero. This is to avoid creating a large number of buckets if observations fluctuate around zero.nativeBucketsForPositiveValues- must not benull. UseNativeHistogramBuckets.EMPTYif empty.nativeBucketsForNegativeValues- must not benull. UseNativeHistogramBuckets.EMPTYif empty.sum- sum of all observed values. Optional, useDouble.NaNif not available.labels- must not be null. UseLabels.EMPTYif there are no labels.exemplars- must not be null. UseExemplars.EMPTYif there are no Exemplars.createdTimestampMillis- timestamp (as inSystem.currentTimeMillis()) when the time series (this specific set of labels) was created (or reset to zero). It's optional. Use0Lif there is no created timestamp.
-
HistogramDataPointSnapshot
public HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, double nativeZeroThreshold, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis, long scrapeTimestampMillis) Constructor with an additional scrape timestamp. This is only useful in rare cases as the scrape timestamp is usually set by the Prometheus server during scraping. Exceptions include mirroring metrics with given timestamps from other metric sources. -
HistogramDataPointSnapshot
private HistogramDataPointSnapshot(ClassicHistogramBuckets classicBuckets, int nativeSchema, double sum, Labels labels, Exemplars exemplars, long createdTimestampMillis, long scrapeTimestampMillis, long count, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues, long nativeZeroCount, double nativeZeroThreshold, boolean internal)
-
-
Method Details
-
calculateCount
private static long calculateCount(ClassicHistogramBuckets classicBuckets, int nativeSchema, long nativeZeroCount, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues) -
calculateClassicCount
-
calculateNativeCount
private static long calculateNativeCount(long nativeZeroCount, NativeHistogramBuckets nativeBucketsForPositiveValues, NativeHistogramBuckets nativeBucketsForNegativeValues) -
hasClassicHistogramData
public boolean hasClassicHistogramData() -
hasNativeHistogramData
public boolean hasNativeHistogramData() -
getClassicBuckets
Will return garbage ifhasClassicHistogramData()isfalse. -
getNativeSchema
public int getNativeSchema()The schema defines the scale of the native histogram, i.g. the granularity of the buckets. Current supported values are -4 <= schema <= 8. SeeNativeHistogramBucketsfor more info. This will return garbage ifhasNativeHistogramData()isfalse. -
getNativeZeroCount
public long getNativeZeroCount()Number of observed zero values. Will return garbage ifhasNativeHistogramData()isfalse. -
getNativeZeroThreshold
public double getNativeZeroThreshold()All observations in [-nativeZeroThreshold; +nativeZeroThreshold] are treated as zero. This is useful to avoid creation of a large number of buckets if observations fluctuate around zero. Will return garbage ifhasNativeHistogramData()isfalse. -
getNativeBucketsForPositiveValues
Will return garbage ifhasNativeHistogramData()isfalse. -
getNativeBucketsForNegativeValues
Will return garbage ifhasNativeHistogramData()isfalse. -
validate
private void validate() -
escape
- Specified by:
escapein classDataPointSnapshot
-
builder
-