Documentation ¶
Index ¶
- Constants
- func CreateFactoryMap[K any](factories ...Factory[K]) map[string]Factory[K]
- type Arguments
- type BoolExpr
- type CreateFunctionFunc
- type Enum
- type EnumParser
- type EnumSymbol
- type ErrorMode
- type Expr
- type ExprFunc
- type Factory
- type FactoryOption
- type Field
- type FloatGetter
- type FloatLikeGetter
- type FunctionContext
- type GetSetter
- type Getter
- type IntGetter
- type IntLikeGetter
- type Key
- type Option
- type PMapGetter
- type Parser
- type Path
- type PathExpressionParser
- type Setter
- type StandardFloatGetter
- type StandardFloatLikeGetter
- type StandardGetSetter
- type StandardIntGetter
- type StandardIntLikeGetter
- type StandardPMapGetter
- type StandardStringGetter
- type StandardStringLikeGetter
- type Statement
- type Statements
- type StatementsOption
- type StringGetter
- type StringLikeGetter
- type TypeError
Constants ¶
const ( EQ compareOp = iota NE LT LTE GTE GT )
These are the allowed values of a compareOp
const ( ADD mathOp = iota SUB MULT DIV )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Arguments ¶ added in v0.77.0
type Arguments interface{}
Arguments holds the arguments for an OTTL function, with arguments specified as fields on a struct. Argument ordering is defined
type BoolExpr ¶ added in v0.64.0
type BoolExpr[K any] struct { // contains filtered or unexported fields }
type CreateFunctionFunc ¶ added in v0.77.0
type CreateFunctionFunc[K any] func(fCtx FunctionContext, args Arguments) (ExprFunc[K], error)
type EnumParser ¶
type EnumParser func(*EnumSymbol) (*Enum, error)
type EnumSymbol ¶
type EnumSymbol string
type ErrorMode ¶ added in v0.71.0
type ErrorMode string
func (*ErrorMode) UnmarshalText ¶ added in v0.72.0
type Factory ¶ added in v0.77.0
type Factory[K any] interface { // Name is the canonical name to be used by the user when invocating // the function generated by this Factory. Name() string // CreateDefaultArguments initializes an Arguments struct specific to this // Factory containing the arguments for the function. CreateDefaultArguments() Arguments // CreateFunction creates an OTTL function that will use the given Arguments. CreateFunction(fCtx FunctionContext, args Arguments) (ExprFunc[K], error) // contains filtered or unexported methods }
Factory defines an OTTL function factory that will generate an OTTL function to be called within a statement.
func NewFactory ¶ added in v0.77.0
func NewFactory[K any](name string, args Arguments, createFunctionFunc CreateFunctionFunc[K], options ...FactoryOption[K]) Factory[K]
type FactoryOption ¶ added in v0.77.0
type FactoryOption[K any] func(factory *factory[K])
type FloatGetter ¶ added in v0.78.0
type FloatGetter[K any] interface { // Get retrieves a float64 value. Get(ctx context.Context, tCtx K) (float64, error) }
FloatGetter is a Getter that must return a float64.
type FloatLikeGetter ¶ added in v0.78.0
type FloatLikeGetter[K any] interface { // Get retrieves a float64 value. // Unlike `FloatGetter`, the expectation is that the underlying value is converted to a float64 if possible. // If the value cannot be converted to a float64, nil and an error are returned. // If the value is nil, nil is returned without an error. Get(ctx context.Context, tCtx K) (*float64, error) }
FloatLikeGetter is a Getter that returns a float64 by converting the underlying value to a float64 if necessary.
type FunctionContext ¶ added in v0.77.0
type FunctionContext struct {
Set component.TelemetrySettings
}
FunctionContext contains data provided by the Collector component to the OTTL for use in functions.
type IntGetter ¶ added in v0.72.0
type IntGetter[K any] interface { // Get retrieves an int64 value. Get(ctx context.Context, tCtx K) (int64, error) }
IntGetter is a Getter that must return an int64.
type IntLikeGetter ¶ added in v0.78.0
type IntLikeGetter[K any] interface { // Get retrieves an int value. // Unlike `IntGetter`, the expectation is that the underlying value is converted to an int if possible. // If the value cannot be converted to an int, nil and an error are returned. // If the value is nil, nil is returned without an error. Get(ctx context.Context, tCtx K) (*int64, error) }
IntLikeGetter is a Getter that returns an int by converting the underlying value to an int if necessary.
type Option ¶ added in v0.70.0
func WithEnumParser ¶ added in v0.70.0
func WithEnumParser[K any](parser EnumParser) Option[K]
type PMapGetter ¶ added in v0.75.0
type PMapGetter[K any] interface { // Get retrieves a pcommon.Map value. Get(ctx context.Context, tCtx K) (pcommon.Map, error) }
PMapGetter is a Getter that must return a pcommon.Map.
type Parser ¶
type Parser[K any] struct { // contains filtered or unexported fields }
func NewParser ¶
func NewParser[K any]( functions map[string]Factory[K], pathParser PathExpressionParser[K], settings component.TelemetrySettings, options ...Option[K], ) (Parser[K], error)
func (*Parser[K]) ParseStatement ¶ added in v0.72.0
func (*Parser[K]) ParseStatements ¶
ParseStatements parses string statements into ottl.Statement objects ready for execution. Returns a slice of statements and a nil error on successful parsing. If parsing fails, returns an empty slice with a multierr error containing an error per failed statement.
type Path ¶
type Path struct {
Fields []Field `parser:"@@ ( '.' @@ )*"`
}
Path represents a telemetry path mathExpression.
type StandardFloatGetter ¶ added in v0.79.0
type StandardFloatGetter[K any] struct { Getter func(ctx context.Context, tCtx K) (interface{}, error) }
StandardFloatGetter is a basic implementation of FloatGetter
type StandardFloatLikeGetter ¶ added in v0.78.0
type StandardGetSetter ¶
type StandardGetSetter[K any] struct { Getter func(ctx context.Context, tCtx K) (interface{}, error) Setter func(ctx context.Context, tCtx K, val interface{}) error }
type StandardIntGetter ¶ added in v0.79.0
type StandardIntGetter[K any] struct { Getter func(ctx context.Context, tCtx K) (interface{}, error) }
StandardIntGetter is a basic implementation of IntGetter
type StandardIntLikeGetter ¶ added in v0.78.0
type StandardPMapGetter ¶ added in v0.79.0
type StandardPMapGetter[K any] struct { Getter func(ctx context.Context, tCtx K) (interface{}, error) }
StandardPMapGetter is a basic implementation of PMapGetter
type StandardStringGetter ¶ added in v0.79.0
type StandardStringGetter[K any] struct { Getter func(ctx context.Context, tCtx K) (interface{}, error) }
StandardStringGetter is a basic implementation of StringGetter
type StandardStringLikeGetter ¶ added in v0.75.0
type Statement ¶
type Statement[K any] struct { // contains filtered or unexported fields }
Statement holds a top level Statement for processing telemetry data. A Statement is a combination of a function invocation and the boolean expression to match telemetry for invoking the function.
func (*Statement[K]) Execute ¶ added in v0.62.0
Execute is a function that will execute the statement's function if the statement's condition is met. Returns true if the function was run, returns false otherwise. If the statement contains no condition, the function will run and true will be returned. In addition, the functions return value is always returned.
type Statements ¶ added in v0.71.0
type Statements[K any] struct { // contains filtered or unexported fields }
Statements represents a list of statements that will be executed sequentially for a TransformContext.
func NewStatements ¶ added in v0.72.0
func NewStatements[K any](statements []*Statement[K], telemetrySettings component.TelemetrySettings, options ...StatementsOption[K]) Statements[K]
func (*Statements[K]) Eval ¶ added in v0.73.0
func (s *Statements[K]) Eval(ctx context.Context, tCtx K) (bool, error)
Eval returns true if any statement's condition is true and returns false otherwise. Does not execute the statement's function. When errorMode is `propagate`, errors cause the evaluation to be false and an error is returned. When errorMode is `ignore`, errors cause evaluation to continue to the next statement.
type StatementsOption ¶ added in v0.72.0
type StatementsOption[K any] func(*Statements[K])
func WithErrorMode ¶ added in v0.72.0
func WithErrorMode[K any](errorMode ErrorMode) StatementsOption[K]
type StringGetter ¶ added in v0.72.0
type StringGetter[K any] interface { // Get retrieves a string value. Get(ctx context.Context, tCtx K) (string, error) }
StringGetter is a Getter that must return a string.
type StringLikeGetter ¶ added in v0.75.0
type StringLikeGetter[K any] interface { // Get retrieves a string value. // Unlike `StringGetter`, the expectation is that the underlying value is converted to a string if possible. // If the value cannot be converted to a string, nil and an error are returned. // If the value is nil, nil is returned without an error. Get(ctx context.Context, tCtx K) (*string, error) }
StringLikeGetter is a Getter that returns a string by converting the underlying value to a string if necessary.