Documentation
¶
Overview ¶
Package traceql contains TraceQL parser and AST definitions.
Index ¶
- Constants
- func ExtractMatchers(expr Expr) (SpansetOp, []SpanMatcher)
- func IntrinsicNames() (r []string)
- type AggregateOp
- type AggregateScalarExpr
- type Attribute
- type AttributeScope
- type Autocomplete
- type BinaryExpr
- type BinaryFieldExpr
- type BinaryOp
- func (op BinaryOp) CheckType(t StaticType) bool
- func (op BinaryOp) IsArithmetic() bool
- func (op BinaryOp) IsBoolean() bool
- func (op BinaryOp) IsEqual() bool
- func (op BinaryOp) IsLogic() bool
- func (op BinaryOp) IsOrdering() bool
- func (op BinaryOp) IsRegex() bool
- func (op BinaryOp) Precedence() int
- func (op BinaryOp) String() string
- type BinaryScalarExpr
- type BinarySpansetExpr
- type CoalesceOperation
- type CompareOperation
- type Expr
- type FieldExpr
- type GroupOperation
- type MetricsAggregation
- type MetricsBinaryExpr
- type MetricsExpr
- type MetricsFilter
- type MetricsOp
- type MetricsPipeline
- type MetricsScalarOp
- type MetricsStage
- type MetricsStageOp
- type PipelineStage
- type ScalarExpr
- type ScalarFilter
- type SelectOperation
- type SpanMatcher
- type SpanProperty
- type SpansetExpr
- type SpansetFilter
- type SpansetOp
- type SpansetPipeline
- type Static
- func (s *Static) AsBool() bool
- func (s *Static) AsDuration() time.Duration
- func (s *Static) AsInt() int64
- func (s *Static) AsNumber() float64
- func (s *Static) AsSpanKind() ptrace.SpanKind
- func (s *Static) AsSpanStatus() ptrace.StatusCode
- func (s *Static) AsString() string
- func (s *Static) Compare(to Static) int
- func (s *Static) IsNil() bool
- func (s *Static) SetBool(v bool)
- func (s *Static) SetDuration(v time.Duration)
- func (s *Static) SetInt(v int64)
- func (s *Static) SetNil()
- func (s *Static) SetNumber(v float64)
- func (s *Static) SetOTELValue(val pcommon.Value) bool
- func (s *Static) SetSpanKind(kind ptrace.SpanKind)
- func (s *Static) SetSpanStatus(status ptrace.StatusCode)
- func (s *Static) SetString(v string)
- func (s *Static) ToFloat() float64
- func (s *Static) ValueType() StaticType
- type StaticType
- type SyntaxError
- type TopKOperation
- type TypeError
- type TypedExpr
- type UnaryFieldExpr
- type UnaryOp
Constants ¶
const ( // DefaultCompareTopN is a default [CompareOperation.TopN]. DefaultCompareTopN = 10 // MaxCompareTopN is a maximum [CompareOperation.TopN]. MaxCompareTopN = 1000 )
Variables ¶
This section is empty.
Functions ¶
func ExtractMatchers ¶
func ExtractMatchers(expr Expr) (SpansetOp, []SpanMatcher)
ExtractMatchers returns SpanMatcher list extracted from Expr.
func IntrinsicNames ¶
func IntrinsicNames() (r []string)
IntrinsicNames returns a slice of intrinsics.
Types ¶
type AggregateOp ¶
type AggregateOp int
AggregateOp defines aggregation operator.
const ( AggregateOpCount AggregateOp = iota + 1 AggregateOpMax AggregateOpMin AggregateOpAvg AggregateOpSum )
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 ParseAttribute ¶
ParseAttribute parses attribute from given string.
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 ScopeInstrumentation ScopeEvent ScopeLink )
func (AttributeScope) String ¶
func (s AttributeScope) String() string
String implements fmt.Stringer.
type Autocomplete ¶
type Autocomplete struct {
Matchers []SpanMatcher
}
Autocomplete is a AND set of spanset matchers.
func ParseAutocomplete ¶
func ParseAutocomplete(input string) Autocomplete
ParseAutocomplete parses matchers from potentially uncomplete TraceQL spanset filter from string.
func (Autocomplete) String ¶
func (c Autocomplete) String() string
String implements fmt.Stringer for Autocomplete.
type BinaryExpr ¶
BinaryExpr is a binary expression.
type BinaryFieldExpr ¶
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.
func (BinaryOp) CheckType ¶
func (op BinaryOp) CheckType(t StaticType) bool
CheckType checks if operator can be applied to given type.
func (BinaryOp) IsArithmetic ¶
IsArithmetic whether op is arithmetic operator.
func (BinaryOp) IsOrdering ¶
IsOrdering whether op is ordering operator.
func (BinaryOp) Precedence ¶
Precedence returns operator precedence.
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 CompareOperation ¶ added in v0.49.0
type CompareOperation struct {
// Spanset is a pipeline producing spans to compare.
Spanset Expr
// Filter selects spans of the selection group.
Filter *SpansetFilter
// TopN limits values returned per attribute.
TopN int
// Start and End constrain the selection window, in Unix nanoseconds.
//
// Both are zero if unset.
Start, End int64
}
CompareOperation is a `compare()` metrics aggregation.
It splits spans into a selection matching Filter and a baseline of the rest, returning a series per attribute value found on them.
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is a TraceQL expression.
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 MetricsAggregation ¶ added in v0.49.0
type MetricsAggregation struct {
Op MetricsOp
// Spanset is a pipeline producing spans to aggregate.
Spanset Expr
// Field is an attribute to aggregate, set if [MetricsOp.TakesField].
Field *Attribute
// Parameters are quantiles of [MetricsOpQuantileOverTime].
Parameters []float64
// By is a set of attributes to group series by, may be empty.
By []Attribute
}
MetricsAggregation aggregates a spanset pipeline into a time series.
type MetricsBinaryExpr ¶ added in v0.49.0
type MetricsBinaryExpr struct {
Left MetricsExpr
Op BinaryOp
Right MetricsExpr
}
MetricsBinaryExpr is an arithmetic operation between two metrics expressions.
type MetricsExpr ¶ added in v0.49.0
type MetricsExpr interface {
Expr
// contains filtered or unexported methods
}
MetricsExpr is a TraceQL metrics query expression.
See https://grafana.com/docs/tempo/latest/traceql/metrics-queries/.
type MetricsFilter ¶ added in v0.49.0
MetricsFilter drops series points not matching the comparison.
type MetricsOp ¶ added in v0.49.0
type MetricsOp int
MetricsOp defines a metrics aggregation operator.
func (MetricsOp) TakesField ¶ added in v0.49.0
TakesField whether op aggregates over a span attribute.
type MetricsPipeline ¶ added in v0.49.0
type MetricsPipeline struct {
Expr MetricsExpr
Stages []MetricsStage
}
MetricsPipeline applies second stage operations to a metrics expression.
type MetricsScalarOp ¶ added in v0.49.0
type MetricsScalarOp struct {
Op BinaryOp
Value float64
// ScalarLeft whether the constant is the left operand, as in `2 / ({} | rate())`.
ScalarLeft bool
}
MetricsScalarOp applies constant arithmetic to every series point.
A duration cannot be used as a scalar operand, so a float carries the value without loss.
type MetricsStage ¶ added in v0.49.0
type MetricsStage interface {
// contains filtered or unexported methods
}
MetricsStage is a metrics query second stage operation.
See https://grafana.com/docs/tempo/latest/traceql/metrics-queries/#multi-stage-metrics-queries.
type MetricsStageOp ¶ added in v0.49.0
type MetricsStageOp int
MetricsStageOp defines a metrics second stage operator.
const ( MetricsStageOpTopK MetricsStageOp = iota + 1 MetricsStageOpBottomK )
func (MetricsStageOp) String ¶ added in v0.49.0
func (op MetricsStageOp) String() string
String implements fmt.Stringer.
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 SpanMatcher ¶
type SpanMatcher struct {
Attribute Attribute
Op BinaryOp // could be zero, look for spans with such attribute
Static Static
}
SpanMatcher defines span predicate to select.
type SpanProperty ¶
type SpanProperty uint8
SpanProperty is a span property.
const ( SpanAttribute SpanProperty = iota SpanDuration SpanChildCount SpanName SpanStatus SpanKind SpanParent RootSpanName RootServiceName TraceDuration // Scoped intrinsics added with TraceQL v2. SpanStatusMessage NestedSetLeft NestedSetRight NestedSetParent SpanID ParentID TraceID EventName EventTimeSinceStart LinkTraceID LinkSpanID InstrumentationName InstrumentationVersion )
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 SpansetOpParent SpansetOpAncestor SpansetOpNotChild SpansetOpNotParent SpansetOpNotDescendant SpansetOpNotAncestor SpansetOpNotSibling SpansetOpUnionChild SpansetOpUnionParent SpansetOpUnionDescendant SpansetOpUnionAncestor SpansetOpUnionSibling )
func (SpansetOp) IsStructural ¶ added in v0.49.0
IsStructural whether op relates two spansets by their position in the trace tree, rather than by set membership.
func (SpansetOp) Precedence ¶
Precedence returns operator precedence.
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) AsDuration ¶
AsDuration returns Duration value.
func (*Static) AsSpanKind ¶
AsSpanKind returns SpanKind value.
func (*Static) AsSpanStatus ¶
func (s *Static) AsSpanStatus() ptrace.StatusCode
AsSpanStatus returns SpanStatus value.
func (*Static) SetDuration ¶
SetDuration sets Duration value.
func (*Static) SetOTELValue ¶
SetOTELValue sets value from given OpenTelemetry data value.
SetOTELValue returns false, if pcommon.Value cannot be represent as Static.
func (*Static) SetSpanKind ¶
SetSpanKind sets SpanKind value.
func (*Static) SetSpanStatus ¶
func (s *Static) SetSpanStatus(status ptrace.StatusCode)
SetSpanStatus sets SpanStatus 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 StaticTypeFromValueType ¶
func StaticTypeFromValueType(typ pcommon.ValueType) StaticType
StaticTypeFromValueType converts pcommon.ValueType to StaticType.
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.
type SyntaxError ¶
SyntaxError is a syntax error.
type TopKOperation ¶ added in v0.49.0
type TopKOperation struct {
Op MetricsStageOp
Limit int
}
TopKOperation is a `topk()`/`bottomk()` operation, keeping only Limit series with the highest (or lowest) values.
type TypedExpr ¶
type TypedExpr interface {
ValueType() StaticType
}
TypedExpr is an interface for typed expression.
type UnaryFieldExpr ¶
UnaryFieldExpr is a unary field expression operation.
func (*UnaryFieldExpr) ValueType ¶
func (s *UnaryFieldExpr) ValueType() StaticType
ValueType returns value type of expression.
Source Files
¶
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. |