annotations

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 49

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Currently there are only 2 types, warnings and info.
	// For now, info are visually identical with warnings as we have not updated
	// the API spec or the frontend to show a different kind of warning. But we
	// make the distinction here to prepare for adding them in future.
	PromQLInfo    = errors.New("PromQL info")
	PromQLWarning = errors.New("PromQL warning")

	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 metric name", PromQLWarning)
	MixedClassicNativeHistogramsWarning = fmt.Errorf("%w: vector contains a mix of classic and native histograms for metric name", PromQLWarning)

	PossibleNonCounterInfo                  = fmt.Errorf("%w: metric might not be a counter, name does not end in _total/_sum/_count/_bucket:", PromQLInfo)
	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) for metric name", PromQLInfo)
)

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 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 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 NewMixedClassicNativeHistogramsWarning

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

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

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 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.

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, maxAnnos int) []string

AsStrings is a convenience function to return the annotations map as a slice of strings. 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 annotations returned here with maxAnnos (0 for no limit).

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.

Jump to

Keyboard shortcuts

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