common

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFunctions added in v0.49.0

func DefaultFunctions() map[string]interface{}

Types

type Condition

type Condition struct {
	Left  Value  `@@`
	Op    string `@("==" | "!=")`
	Right Value  `@@`
}

Condition represents an optional boolean condition on the RHS of a query. nolint:govet

type ExprFunc added in v0.49.0

type ExprFunc func(ctx TransformContext) interface{}

func NewFunctionCall added in v0.49.0

func NewFunctionCall(inv Invocation, functions map[string]interface{}, pathParser PathExpressionParser) (ExprFunc, error)

TODO(anuraaga): See if reflection can be avoided without complicating definition of transform functions. Visible for testing

type Field

type Field struct {
	Name   string  `@Ident`
	MapKey *string `( "[" @String "]" )?`
}

Field is an item within a Path. nolint:govet

type GetSetter added in v0.49.0

type GetSetter interface {
	Getter
	Setter
}

type Getter added in v0.49.0

type Getter interface {
	Get(ctx TransformContext) interface{}
}

func NewGetter added in v0.49.0

func NewGetter(val Value, functions map[string]interface{}, pathParser PathExpressionParser) (Getter, error)

type Invocation

type Invocation struct {
	Function  string  `@Ident`
	Arguments []Value `"(" ( @@ ( "," @@ )* )? ")"`
}

Invocation represents a function call. nolint:govet

type ParsedQuery added in v0.45.0

type ParsedQuery struct {
	Invocation Invocation `@@`
	Condition  *Condition `( "where" @@ )?`
}

ParsedQuery represents a parsed query. It is the entry point into the query DSL. nolint:govet

type Path

type Path struct {
	Fields []Field `@@ ( "." @@ )*`
}

Path represents a telemetry path expression. nolint:govet

type PathExpressionParser added in v0.49.0

type PathExpressionParser func(*Path) (GetSetter, error)

type Query

type Query struct {
	Function  ExprFunc
	Condition condFunc
}

Query holds a top level Query for processing telemetry data. A Query is a combination of a function invocation and the condition to match telemetry for invoking the function.

func ParseQueries added in v0.49.0

func ParseQueries(statements []string, functions map[string]interface{}, pathParser PathExpressionParser) ([]Query, error)

type Setter added in v0.49.0

type Setter interface {
	Set(ctx TransformContext, val interface{})
}

type TransformContext added in v0.49.0

type TransformContext interface {
	GetItem() interface{}
	GetInstrumentationScope() pcommon.InstrumentationScope
	GetResource() pcommon.Resource
}

type Value

type Value struct {
	Invocation *Invocation `( @@`
	String     *string     `| @String`
	Float      *float64    `| @Float`
	Int        *int64      `| @Int`
	Path       *Path       `| @@ )`
}

Value represents a part of a parsed query which is resolved to a value of some sort. This can be a telemetry path expression, function call, or literal. nolint:govet

Jump to

Keyboard shortcuts

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