utils

package
v0.71.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindPosition added in v0.71.0

func FindPosition(expr string, within posrange.PositionRange, fn string) posrange.PositionRange

FIXME sum() on ().

func GetQueryFragment added in v0.71.0

func GetQueryFragment(expr string, pos posrange.PositionRange) string

func HasOuterBinaryExpr added in v0.8.0

func HasOuterBinaryExpr(node *parser.PromQLNode) *promParser.BinaryExpr

func HasOuterRate added in v0.28.0

func HasOuterRate(node *parser.PromQLNode) (calls []*promParser.Call)

func HasVectorSelector added in v0.4.1

func HasVectorSelector(node *parser.PromQLNode) (vs []promParser.VectorSelector)

func RemoveConditions added in v0.10.1

func RemoveConditions(source string) promParser.Node

RemoveConditions takes a *valid* PromQL expression and removes any condition from it.

Types

type ExcludedLabel added in v0.67.0

type ExcludedLabel struct {
	Reason   string
	Fragment posrange.PositionRange
}

type Join added in v0.71.0

type Join struct {
	Src Source
}

type Source added in v0.67.0

type Source struct {
	Selector         *promParser.VectorSelector // Vector selector used for this source.
	Call             *promParser.Call           // Most outer call used inside this source.
	Aggregation      *promParser.AggregateExpr  // Most outer aggregation expression used inside this source.
	ExcludeReason    map[string]ExcludedLabel   // Reason why a label was excluded
	Operation        string
	IsDeadReason     string
	Returns          promParser.ValueType
	Joins            []Join   // Any other sources this source joins with.
	Unless           []Join   // Any other sources this source is suppressed by.
	IncludedLabels   []string // Labels that are included by filters, they will be present if exist on source series (by).
	ExcludedLabels   []string // Labels guaranteed to be excluded from the results (without).
	GuaranteedLabels []string // Labels guaranteed to be present on the results (matchers).
	Position         posrange.PositionRange
	ReturnedNumber   float64 // If AlwaysReturns=true this is the number that's returned
	Type             SourceType
	FixedLabels      bool // Labels are fixed and only allowed labels can be present.
	IsDead           bool // True if this source cannot be reached and is dead code.
	AlwaysReturns    bool // True if this source always returns results.
	KnownReturn      bool // True if we always know the return value.
	IsConditional    bool // True if this source is guarded by 'foo > 5' or other condition.
}

FIXME remove Selector/Call/Aggregation? Use a single parser.Node instead?

func LabelsSource added in v0.67.0

func LabelsSource(expr string, node promParser.Node) (src []Source)

func (Source) CanHaveLabel added in v0.71.0

func (s Source) CanHaveLabel(name string) bool

func (Source) Fragment added in v0.71.0

func (s Source) Fragment(expr string) string

func (Source) GetSmallestPosition added in v0.71.0

func (s Source) GetSmallestPosition() (pr posrange.PositionRange)

func (Source) LabelExcludeReason added in v0.71.0

func (s Source) LabelExcludeReason(name string) ExcludedLabel

func (Source) WalkSources added in v0.71.0

func (s Source) WalkSources(fn Visitor)

type SourceType added in v0.67.0

type SourceType int
const (
	UnknownSource SourceType = iota
	NumberSource
	StringSource
	SelectorSource
	FuncSource
	AggregateSource
)

type Visitor added in v0.71.0

type Visitor func(s Source)

Jump to

Keyboard shortcuts

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