annotations

package
v0.307.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 69

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PromQLInfo    = errors.New("PromQL info")
	PromQLWarning = errors.New("PromQL warning")

	InvalidRatioWarning                        = fmt.Errorf("%w: ratio value should be between -1 and 1", PromQLWarning)
	InvalidQuantileWarning                     = fmt.Errorf("%w: quantile value should be between 0 and 1", PromQLWarning)
	BadBucketLabelWarning                      = fmt.Errorf("%w: bucket label %q is missing or has a malformed value", PromQLWarning, model.BucketLabel)
	MixedFloatsHistogramsWarning               = fmt.Errorf("%w: encountered a mix of histograms and floats for", PromQLWarning)
	MixedClassicNativeHistogramsWarning        = fmt.Errorf("%w: vector contains a mix of classic and native histograms", PromQLWarning)
	NativeHistogramNotCounterWarning           = fmt.Errorf("%w: this native histogram metric is not a counter:", PromQLWarning)
	NativeHistogramNotGaugeWarning             = fmt.Errorf("%w: this native histogram metric is not a gauge:", PromQLWarning)
	MixedExponentialCustomHistogramsWarning    = fmt.Errorf("%w: vector contains a mix of histograms with exponential and custom buckets schemas for metric name", PromQLWarning)
	IncompatibleCustomBucketsHistogramsWarning = fmt.Errorf("%w: vector contains histograms with incompatible custom buckets for metric name", PromQLWarning)
	IncompatibleBucketLayoutInBinOpWarning     = fmt.Errorf("%w: incompatible bucket layout encountered for binary operator", PromQLWarning)

	PossibleNonCounterInfo                  = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo)
	PossibleNonCounterLabelInfo             = fmt.Errorf("%w: metric might not be a counter, __type__ label is not set to %q or %q", PromQLInfo, model.MetricTypeCounter, model.MetricTypeHistogram)
	HistogramQuantileForcedMonotonicityInfo = fmt.Errorf("%w: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)", PromQLInfo)
	IncompatibleTypesInBinOpInfo            = fmt.Errorf("%w: incompatible sample types encountered for binary operator", PromQLInfo)
	HistogramIgnoredInAggregationInfo       = fmt.Errorf("%w: ignored histogram in", PromQLInfo)
	HistogramIgnoredInMixedRangeInfo        = fmt.Errorf("%w: ignored histograms in a range containing both floats and histograms for metric name", PromQLInfo)
	NativeHistogramQuantileNaNResultInfo    = fmt.Errorf("%w: input to histogram_quantile has NaN observations, result is NaN", PromQLInfo)
	NativeHistogramQuantileNaNSkewInfo      = fmt.Errorf("%w: input to histogram_quantile has NaN observations, result is skewed higher", PromQLInfo)
	NativeHistogramFractionNaNsInfo         = fmt.Errorf("%w: input to histogram_fraction has NaN observations, which are excluded from all fractions", PromQLInfo)
	HistogramCounterResetCollisionWarning   = fmt.Errorf("%w: conflicting counter resets during histogram", PromQLWarning)
)

Functions

func NewBadBucketLabelWarning

func NewBadBucketLabelWarning(metricName, label string, pos posrange.PositionRange) error

NewBadBucketLabelWarning is used when there is an error parsing the bucket label of a classic histogram.

func NewHistogramCounterResetCollisionWarning added in v0.307.0

func NewHistogramCounterResetCollisionWarning(pos posrange.PositionRange, operation HistogramOperation) error

NewHistogramCounterResetCollisionWarning is used when two counter histograms are added or subtracted where one has a CounterReset hint and the other has NotCounterReset.

func NewHistogramIgnoredInAggregationInfo added in v0.301.0

func NewHistogramIgnoredInAggregationInfo(aggregation string, pos posrange.PositionRange) error

NewHistogramIgnoredInAggregationInfo is used when a histogram is ignored by an aggregation operator that cannot handle histograms.

func NewHistogramIgnoredInMixedRangeInfo added in v0.302.0

func NewHistogramIgnoredInMixedRangeInfo(metricName string, pos posrange.PositionRange) error

NewHistogramIgnoredInMixedRangeInfo is used when a histogram is ignored in a range vector which contains mix of floats and histograms.

func NewHistogramQuantileForcedMonotonicityInfo

func NewHistogramQuantileForcedMonotonicityInfo(metricName string, pos posrange.PositionRange) error

NewHistogramQuantileForcedMonotonicityInfo is used when the input (classic histograms) to histogram_quantile needs to be forced to be monotonic.

func NewIncompatibleBucketLayoutInBinOpWarning added in v0.303.0

func NewIncompatibleBucketLayoutInBinOpWarning(operator string, pos posrange.PositionRange) error

NewIncompatibleBucketLayoutInBinOpWarning is used if binary operators act on a combination of two incompatible histograms.

func NewIncompatibleCustomBucketsHistogramsWarning added in v0.54.0

func NewIncompatibleCustomBucketsHistogramsWarning(metricName string, pos posrange.PositionRange) error

NewIncompatibleCustomBucketsHistogramsWarning is used when the queried series includes custom buckets histograms with incompatible custom bounds.

func NewIncompatibleTypesInBinOpInfo added in v0.300.0

func NewIncompatibleTypesInBinOpInfo(lhsType, operator, rhsType string, pos posrange.PositionRange) error

NewIncompatibleTypesInBinOpInfo is used if binary operators act on a combination of types that doesn't work and therefore returns no result.

func NewInvalidQuantileWarning

func NewInvalidQuantileWarning(q float64, pos posrange.PositionRange) error

NewInvalidQuantileWarning is used when the user specifies an invalid quantile value, i.e. a float that is outside the range [0, 1] or NaN.

func NewInvalidRatioWarning added in v0.54.0

func NewInvalidRatioWarning(q, to float64, pos posrange.PositionRange) error

NewInvalidRatioWarning is used when the user specifies an invalid ratio value, i.e. a float that is outside the range [-1, 1] or NaN.

func NewMixedClassicNativeHistogramsWarning

func NewMixedClassicNativeHistogramsWarning(metricName string, pos posrange.PositionRange) error

NewMixedClassicNativeHistogramsWarning is used when the queried series includes both classic and native histograms.

func NewMixedExponentialCustomHistogramsWarning added in v0.54.0

func NewMixedExponentialCustomHistogramsWarning(metricName string, pos posrange.PositionRange) error

NewMixedExponentialCustomHistogramsWarning is used when the queried series includes histograms with both exponential and custom buckets schemas.

func NewMixedFloatsHistogramsAggWarning added in v0.51.0

func NewMixedFloatsHistogramsAggWarning(pos posrange.PositionRange) error

NewMixedFloatsHistogramsAggWarning is used when the queried series includes both float samples and histogram samples in an aggregation.

func NewMixedFloatsHistogramsWarning

func NewMixedFloatsHistogramsWarning(metricName string, pos posrange.PositionRange) error

NewMixedFloatsHistogramsWarning is used when the queried series includes both float samples and histogram samples for functions that do not support mixed samples.

func NewNativeHistogramFractionNaNsInfo added in v0.305.0

func NewNativeHistogramFractionNaNsInfo(metricName string, pos posrange.PositionRange) error

func NewNativeHistogramNotCounterWarning added in v0.50.0

func NewNativeHistogramNotCounterWarning(metricName string, pos posrange.PositionRange) error

NewNativeHistogramNotCounterWarning is used when histogramRate is called with isCounter set to true on a gauge histogram.

func NewNativeHistogramNotGaugeWarning added in v0.50.0

func NewNativeHistogramNotGaugeWarning(metricName string, pos posrange.PositionRange) error

NewNativeHistogramNotGaugeWarning is used when histogramRate is called with isCounter set to false on a counter histogram.

func NewNativeHistogramQuantileNaNResultInfo added in v0.305.0

func NewNativeHistogramQuantileNaNResultInfo(metricName string, pos posrange.PositionRange) error

func NewNativeHistogramQuantileNaNSkewInfo added in v0.305.0

func NewNativeHistogramQuantileNaNSkewInfo(metricName string, pos posrange.PositionRange) error

func NewPossibleNonCounterInfo

func NewPossibleNonCounterInfo(metricName string, pos posrange.PositionRange) error

NewPossibleNonCounterInfo is used when a named counter metric with only float samples does not have the suffixes _total, _sum, _count, or _bucket.

func NewPossibleNonCounterLabelInfo added in v0.305.0

func NewPossibleNonCounterLabelInfo(metricName, typeLabel string, pos posrange.PositionRange) error

NewPossibleNonCounterLabelInfo is used when a named counter metric with only float samples does not have the __type__ label set to "counter".

Types

type Annotations

type Annotations map[string]error

Annotations is a general wrapper for warnings and other information that is returned by the query API along with the results. Each individual annotation is modeled by a Go error. They are deduplicated based on the string returned by error.Error(). The zero value is usable without further initialization, see New().

func New

func New() *Annotations

New returns new Annotations ready to use. Note that the zero value of Annotations is also fully usable, but using this method is often more readable.

func (*Annotations) Add

func (a *Annotations) Add(err error) Annotations

Add adds an annotation (modeled as a Go error) in-place and returns the modified Annotations for convenience.

func (Annotations) AsErrors

func (a Annotations) AsErrors() []error

AsErrors is a convenience function to return the annotations map as a slice of errors.

func (Annotations) AsStrings

func (a Annotations) AsStrings(query string, maxWarnings, maxInfos int) (warnings, infos []string)

AsStrings is a convenience function to return the annotations map as 2 slices of strings, separated into warnings and infos. The query string is used to get the line number and character offset positioning info of the elements which trigger an annotation. We limit the number of warnings and infos returned here with maxWarnings and maxInfos respectively (0 for no limit).

func (Annotations) CountWarningsAndInfo added in v0.54.0

func (a Annotations) CountWarningsAndInfo() (countWarnings, countInfo int)

CountWarningsAndInfo counts and returns the number of warnings and infos in the annotations wrapper.

func (*Annotations) Merge

func (a *Annotations) Merge(aa Annotations) Annotations

Merge adds the contents of the second annotation to the first, modifying the first in-place, and returns the merged first Annotation for convenience.

type HistogramOperation added in v0.307.0

type HistogramOperation string
const (
	HistogramAdd HistogramOperation = "addition"
	HistogramSub HistogramOperation = "subtraction"
	HistogramAgg HistogramOperation = "aggregation"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL