traceql

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package traceql contains TraceQL parser and AST definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateOp

type AggregateOp int

AggregateOp defines aggregation operator.

const (
	AggregateOpCount AggregateOp = iota + 1
	AggregateOpMax
	AggregateOpMin
	AggregateOpAvg
	AggregateOpSum
)

func (AggregateOp) String

func (op AggregateOp) String() string

String implements fmt.Stringer.

type AggregateScalarExpr

type AggregateScalarExpr struct {
	Op    AggregateOp
	Field FieldExpr // nilable
}

AggregateScalarExpr is an aggregate function.

func (*AggregateScalarExpr) ValueType

func (s *AggregateScalarExpr) ValueType() StaticType

ValueType returns value type of expression.

type Attribute

type Attribute struct {
	Name   string
	Scope  AttributeScope
	Prop   SpanProperty
	Parent bool // refers to parent
}

Attribute is a span attribute.

func (Attribute) String

func (s Attribute) String() string

String implements fmt.Stringer.

func (*Attribute) ValueType

func (s *Attribute) ValueType() StaticType

ValueType returns value type of expression.

type AttributeScope

type AttributeScope uint8

AttributeScope is an attribute scope.

const (
	ScopeNone AttributeScope = iota
	ScopeResource
	ScopeSpan
)

type BinaryExpr

type BinaryExpr struct {
	Left  Expr
	Op    SpansetOp
	Right Expr
}

BinaryExpr is a binary expression.

type BinaryFieldExpr

type BinaryFieldExpr struct {
	Left  FieldExpr
	Op    BinaryOp
	Right FieldExpr
}

BinaryFieldExpr is a binary operation between two field expressions.

func (*BinaryFieldExpr) ValueType

func (s *BinaryFieldExpr) ValueType() StaticType

ValueType returns value type of expression.

type BinaryOp

type BinaryOp int

BinaryOp defines binary operator.

const (
	// Logical ops.
	OpAnd BinaryOp = iota + 1
	OpOr
	// Math ops.
	OpAdd
	OpSub
	OpMul
	OpDiv
	OpMod
	OpPow
	// Comparison ops.
	OpEq
	OpNotEq
	OpRe
	OpNotRe
	OpGt
	OpGte
	OpLt
	OpLte
)

func (BinaryOp) CheckType

func (op BinaryOp) CheckType(t StaticType) bool

CheckType checks if operator can be applied to given type.

func (BinaryOp) IsArithmetic

func (op BinaryOp) IsArithmetic() bool

IsArithmetic whether op is arithmetic operator.

func (BinaryOp) IsBoolean

func (op BinaryOp) IsBoolean() bool

IsBoolean whether op have boolean result.

func (BinaryOp) IsEqual

func (op BinaryOp) IsEqual() bool

IsEqual whether op is equal operator.

func (BinaryOp) IsLogic

func (op BinaryOp) IsLogic() bool

IsLogic whether op is logic operator.

func (BinaryOp) IsOrdering

func (op BinaryOp) IsOrdering() bool

IsOrdering whether op is ordering operator.

func (BinaryOp) IsRegex

func (op BinaryOp) IsRegex() bool

IsRegex whether op is regexp operator.

func (BinaryOp) Precedence

func (op BinaryOp) Precedence() int

Precedence returns operator precedence.

func (BinaryOp) String

func (op BinaryOp) String() string

String implements fmt.Stringer.

type BinaryScalarExpr

type BinaryScalarExpr struct {
	Left  ScalarExpr
	Op    BinaryOp
	Right ScalarExpr
}

BinaryScalarExpr is a binary operation between two scalar expressions.

func (*BinaryScalarExpr) ValueType

func (s *BinaryScalarExpr) ValueType() StaticType

ValueType returns value type of expression.

type BinarySpansetExpr

type BinarySpansetExpr struct {
	Left  SpansetExpr
	Op    SpansetOp
	Right SpansetExpr
}

BinarySpansetExpr is a binary operation between two spanset expressions.

type CoalesceOperation

type CoalesceOperation struct{}

CoalesceOperation is a `colaesce()` operation.

type Expr

type Expr interface {
	// contains filtered or unexported methods
}

Expr is a TraceQL expression.

func Parse

func Parse(input string) (Expr, error)

Parse parses TraceQL query from string.

type FieldExpr

type FieldExpr interface {
	TypedExpr
	// contains filtered or unexported methods
}

FieldExpr is a field expression.

type GroupOperation

type GroupOperation struct {
	By FieldExpr
}

GroupOperation is a `by()` operation.

type PipelineStage

type PipelineStage interface {
	// contains filtered or unexported methods
}

PipelineStage is a pipeline stage.

type ScalarExpr

type ScalarExpr interface {
	TypedExpr
	// contains filtered or unexported methods
}

ScalarExpr is a scalar expression.

type ScalarFilter

type ScalarFilter struct {
	Left  ScalarExpr
	Op    BinaryOp
	Right ScalarExpr
}

ScalarFilter is a scalar filter.

type SelectOperation

type SelectOperation struct {
	Args []FieldExpr
}

SelectOperation is a `select()` operation.

type SpanProperty

type SpanProperty uint8

SpanProperty is a span property.

const (
	SpanAttribute SpanProperty = iota
	SpanDuration
	SpanChildCount
	SpanName
	SpanStatus
	SpanKind
	SpanParent
	RootSpanName
	RootServiceName
	TraceDuration
)

type SpansetExpr

type SpansetExpr interface {
	PipelineStage
	// contains filtered or unexported methods
}

SpansetExpr is a spanset expression.

type SpansetFilter

type SpansetFilter struct {
	Expr FieldExpr // if filter is empty, expr is True
}

SpansetFilter is a spanset filter.

type SpansetOp

type SpansetOp int

SpansetOp defines spanset operator.

const (
	SpansetOpAnd SpansetOp = iota + 1
	SpansetOpChild
	SpansetOpDescendant
	SpansetOpUnion
	SpansetOpSibling
)

func (SpansetOp) Precedence

func (op SpansetOp) Precedence() int

Precedence returns operator precedence.

func (SpansetOp) String

func (op SpansetOp) String() string

String implements fmt.Stringer.

type SpansetPipeline

type SpansetPipeline struct {
	Pipeline []PipelineStage
}

SpansetPipeline is a spanset pipeline.

type Static

type Static struct {
	Type StaticType
	Data uint64 // stores everything, except strings
	Str  string
}

Static is a constant value.

func (*Static) AsBool

func (s *Static) AsBool() bool

AsBool returns Bool value.

func (*Static) AsDuration

func (s *Static) AsDuration() time.Duration

AsDuration returns Duration value.

func (*Static) AsFloat

func (s *Static) AsFloat() float64

AsFloat converts numeric Static to a float value.

func (*Static) AsInt

func (s *Static) AsInt() int64

AsInt returns Int value.

func (*Static) AsNumber

func (s *Static) AsNumber() float64

AsNumber returns Number value.

func (*Static) AsSpanKind

func (s *Static) AsSpanKind() ptrace.SpanKind

AsSpanKind returns SpanKind value.

func (*Static) AsSpanStatus

func (s *Static) AsSpanStatus() ptrace.StatusCode

AsSpanStatus returns SpanStatus value.

func (*Static) AsString

func (s *Static) AsString() string

AsString returns String value.

func (*Static) Compare

func (s *Static) Compare(to Static) int

Compare compares two Static values.

func (*Static) IsNil

func (s *Static) IsNil() bool

IsNil returns true, if static is Nil.

func (*Static) SetBool

func (s *Static) SetBool(v bool)

SetBool sets Bool value.

func (*Static) SetDuration

func (s *Static) SetDuration(v time.Duration)

SetDuration sets Duration value.

func (*Static) SetInt

func (s *Static) SetInt(v int64)

SetInt sets Int value.

func (*Static) SetNil

func (s *Static) SetNil()

SetNil sets Nil value.

func (*Static) SetNumber

func (s *Static) SetNumber(v float64)

SetNumber sets Number value.

func (*Static) SetOTELValue

func (s *Static) SetOTELValue(val pcommon.Value) bool

SetOTELValue sets value from given OpenTelemetry data value.

SetOTELValue returns false, if pcommon.Value cannot be represent as Static.

func (*Static) SetSpanKind

func (s *Static) SetSpanKind(kind ptrace.SpanKind)

SetSpanKind sets SpanKind value.

func (*Static) SetSpanStatus

func (s *Static) SetSpanStatus(status ptrace.StatusCode)

SetSpanStatus sets SpanStatus value.

func (*Static) SetString

func (s *Static) SetString(v string)

SetString sets String value.

func (*Static) ValueType

func (s *Static) ValueType() StaticType

ValueType returns value type of expression.

type StaticType

type StaticType int

StaticType defines static type.

const (
	TypeAttribute StaticType = iota
	TypeString
	TypeInt
	TypeNumber
	TypeBool
	TypeNil
	TypeDuration
	TypeSpanStatus
	TypeSpanKind
)

func (StaticType) CheckOperand

func (s StaticType) CheckOperand(s2 StaticType) bool

CheckOperand whether is a and b are valid operands.

func (StaticType) IsNumeric

func (s StaticType) IsNumeric() bool

IsNumeric returns true if type is numeric.

func (StaticType) String

func (s StaticType) String() string

String implements fmt.Stringer.

type SyntaxError

type SyntaxError struct {
	Msg string
	Pos scanner.Position
}

SyntaxError is a syntax error.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

Error implements error.

type TypeError

type TypeError struct {
	Msg string
	Pos scanner.Position
}

TypeError is a type checking error.

func (*TypeError) Error

func (e *TypeError) Error() string

Error implements error.

type TypedExpr

type TypedExpr interface {
	ValueType() StaticType
}

TypedExpr is an interface for typed expression.

type UnaryFieldExpr

type UnaryFieldExpr struct {
	Expr FieldExpr
	Op   UnaryOp
}

UnaryFieldExpr is a unary field expression operation.

func (*UnaryFieldExpr) ValueType

func (s *UnaryFieldExpr) ValueType() StaticType

ValueType returns value type of expression.

type UnaryOp

type UnaryOp int

UnaryOp defines unary operator.

const (
	OpNot UnaryOp = iota + 1
	OpNeg
)

func (UnaryOp) CheckType

func (op UnaryOp) CheckType(t StaticType) bool

CheckType checks if operator can be applied to given type.

func (UnaryOp) String

func (op UnaryOp) String() string

String implements fmt.Stringer.

Directories

Path Synopsis
Package lexer contains TraceQL lexer.
Package lexer contains TraceQL lexer.
Package traceqlengine implements TraceQL evaluation engine.
Package traceqlengine implements TraceQL evaluation engine.

Jump to

Keyboard shortcuts

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