Documentation
¶
Index ¶
- func FindArgumentPosition(expr string, within posrange.PositionRange, name string) posrange.PositionRange
- func FindFuncNamePosition(expr string, within posrange.PositionRange, fn string) posrange.PositionRange
- func FindFuncPosition(expr string, within posrange.PositionRange, fn string, ...) posrange.PositionRange
- func GetQueryFragment(expr string, pos posrange.PositionRange) string
- func MostOuterOperation[T promParser.Node](s Source) (T, bool)
- type DeadInfo
- type DeadLabel
- type DeadLabelKind
- type Join
- type LabelPromiseType
- type LabelTransform
- type Operation
- type Operations
- type ReturnInfo
- type Source
- type Type
- type Unless
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindArgumentPosition ¶
func FindArgumentPosition(expr string, within posrange.PositionRange, name string) posrange.PositionRange
func FindFuncNamePosition ¶
func FindFuncNamePosition(expr string, within posrange.PositionRange, fn string) posrange.PositionRange
func FindFuncPosition ¶
func FindFuncPosition(expr string, within posrange.PositionRange, fn string, outside []posrange.PositionRange) posrange.PositionRange
func GetQueryFragment ¶
func GetQueryFragment(expr string, pos posrange.PositionRange) string
func MostOuterOperation ¶
func MostOuterOperation[T promParser.Node](s Source) (T, bool)
Types ¶
type DeadInfo ¶
type DeadInfo struct {
Reason string
Fragment posrange.PositionRange
}
type DeadLabel ¶
type DeadLabel struct {
Name string
Reason string
LabelReason string
UsageFragment posrange.PositionRange
LabelFragment posrange.PositionRange
Kind DeadLabelKind
}
type DeadLabelKind ¶
type DeadLabelKind uint8
const ( ImpossibleDeadLabel DeadLabelKind = iota OrphanedLabel DuplicatedJoin UnusedLabel )
func (DeadLabelKind) String ¶
func (dlk DeadLabelKind) String() string
type LabelPromiseType ¶
type LabelPromiseType uint8
const ( ImpossibleLabel LabelPromiseType = iota PossibleLabel GuaranteedLabel )
func (LabelPromiseType) MarshalYAML ¶
func (lpt LabelPromiseType) MarshalYAML() (any, error)
Used for test snapshots.
type LabelTransform ¶
type LabelTransform struct {
Reason string
Kind LabelPromiseType
Fragment posrange.PositionRange
}
type Operation ¶
type Operation struct {
Node promParser.Node
Operation string
Arguments []string
}
func (Operation) MarshalYAML ¶
Used for test snapshots.
type Operations ¶
type Operations []Operation
type ReturnInfo ¶
type ReturnInfo struct {
LogicalExpr string
ValuePosition posrange.PositionRange
ReturnedNumber float64 // If AlwaysReturns=true this is the number that's returned
AlwaysReturns bool // True if this source always returns results.
KnownReturn bool // True if we always know the return value.
IsReturnBool bool // True if this source uses the 'bool' modifier.
}
type Source ¶
type Source struct {
Labels map[string]LabelTransform `yaml:"labels,omitempty"`
DeadInfo *DeadInfo `yaml:"deadInfo,omitempty"`
DeadLabels []DeadLabel `yaml:"deadLabels,omitempty"`
Returns promParser.ValueType `yaml:"returns"`
Operations Operations `yaml:"operations,omitempty"`
// Any other sources this source joins with.
Joins []Join `yaml:"joins,omitempty"`
// Any other sources this source is suppressed by.
Unless []Unless `yaml:"unless,omitempty"`
UsedLabels []string `yaml:"usedLabels,omitempty"`
ReturnInfo ReturnInfo `yaml:"returnInfo,omitempty"`
Position posrange.PositionRange `yaml:"position"`
Type Type `yaml:"type"`
// Labels are fixed and only allowed labels can be present.
FixedLabels bool `yaml:"fixedLabels,omitempty"`
// True if this source is guarded by 'foo > 5' or other condition.
IsConditional bool `yaml:"isConditional,omitempty"`
}
func LabelsSource ¶
func LabelsSource(expr string, node promParser.Node) (src []Source)
func (Source) CanHaveLabel ¶
func (Source) LabelExcludeReason ¶
func (s Source) LabelExcludeReason(name string) (string, posrange.PositionRange)
func (Source) TransformedLabels ¶
func (s Source) TransformedLabels(kinds ...LabelPromiseType) []string
func (Source) WalkSources ¶
Click to show internal directories.
Click to hide internal directories.