Documentation ¶
Index ¶
- func CreateFactoryMap[K any](factories ...Factory[K]) map[string]Factory[K]
- type Arguments
- type BoolExpr
- type BoolGetter
- type BoolLikeGetter
- type Condition
- type ConditionSequence
- type ConditionSequenceOption
- type CreateFunctionFunc
- type DurationGetter
- type Enum
- type EnumParser
- type EnumSymbol
- type ErrorMode
- type Expr
- type ExprFunc
- type Factory
- type FactoryOption
- type FloatGetter
- type FloatLikeGetter
- type FunctionContext
- type FunctionGetter
- type GetSetter
- type Getter
- type IntGetter
- type IntLikeGetter
- type Key
- type LogicOperation
- type Option
- type Optional
- type PMapGetter
- type Parser
- func (p *Parser[K]) ParseCondition(condition string) (*Condition[K], error)
- func (p *Parser[K]) ParseConditions(conditions []string) ([]*Condition[K], error)
- func (p *Parser[K]) ParseStatement(statement string) (*Statement[K], error)
- func (p *Parser[K]) ParseStatements(statements []string) ([]*Statement[K], error)
- type Path
- type PathExpressionParser
- type Setter
- type StandardBoolGetter
- type StandardBoolLikeGetter
- type StandardDurationGetter
- type StandardFloatGetter
- type StandardFloatLikeGetter
- type StandardFunctionGetter
- type StandardGetSetter
- type StandardIntGetter
- type StandardIntLikeGetter
- type StandardPMapGetter
- type StandardStringGetter
- type StandardStringLikeGetter
- type StandardTimeGetter
- type Statement
- type StatementSequence
- type StatementSequenceOption
- type StringGetter
- type StringLikeGetter
- type TimeGetter
- type TypeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Arguments ¶ added in v0.77.0
type Arguments any
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 BoolGetter ¶ added in v0.89.0
type BoolGetter[K any] interface { // Get retrieves a bool value. Get(ctx context.Context, tCtx K) (bool, error) }
BoolGetter is a Getter that must return a bool.
type BoolLikeGetter ¶ added in v0.89.0
type BoolLikeGetter[K any] interface { // Get retrieves a bool value. // Unlike `BoolGetter`, the expectation is that the underlying value is converted to a bool if possible. // If the value cannot be converted to a bool, nil and an error are returned. // If the value is nil, nil is returned without an error. Get(ctx context.Context, tCtx K) (*bool, error) }
BoolLikeGetter is a Getter that returns a bool by converting the underlying value to a bool if necessary.
type Condition ¶ added in v0.90.0
type Condition[K any] struct { // contains filtered or unexported fields }
Condition holds a top level Condition. A Condition is a boolean expression to match telemetry.
type ConditionSequence ¶ added in v0.91.0
type ConditionSequence[K any] struct { // contains filtered or unexported fields }
ConditionSequence represents a list of Conditions that will be evaluated sequentially for a TransformContext and will handle errors returned by conditions based on an ErrorMode. By default, the conditions are ORed together, but they can be ANDed together using the WithLogicOperation option.
func NewConditionSequence ¶ added in v0.91.0
func NewConditionSequence[K any](conditions []*Condition[K], telemetrySettings component.TelemetrySettings, options ...ConditionSequenceOption[K]) ConditionSequence[K]
NewConditionSequence creates a new ConditionSequence with the provided Condition slice and component.TelemetrySettings. The default ErrorMode is `Propagate` and the default LogicOperation is `OR`. You may also augment the ConditionSequence with a slice of ConditionSequenceOption.
func (*ConditionSequence[K]) Eval ¶ added in v0.91.0
func (c *ConditionSequence[K]) Eval(ctx context.Context, tCtx K) (bool, error)
Eval evaluates the result of each Condition in the ConditionSequence. The boolean logic between conditions is based on the ConditionSequence's Logic Operator. If using the default OR LogicOperation, if any Condition evaluates to true, then true is returned and if all Conditions evaluate to false, then false is returned. If using the AND LogicOperation, if any Condition evaluates to false, then false is returned and if all Conditions evaluate to true, then true is returned. When the ErrorMode of the ConditionSequence is `propagate`, errors cause the evaluation to be false and an error is returned. When the ErrorMode of the ConditionSequence is `ignore`, errors are logged and cause the evaluation to continue to the next condition. When the ErrorMode of the ConditionSequence is `silent`, errors are not logged and cause the evaluation to continue to the next condition. When using the AND LogicOperation with the `ignore` ErrorMode the sequence will evaluate to false if all conditions error.
type ConditionSequenceOption ¶ added in v0.91.0
type ConditionSequenceOption[K any] func(*ConditionSequence[K])
func WithConditionSequenceErrorMode ¶ added in v0.91.0
func WithConditionSequenceErrorMode[K any](errorMode ErrorMode) ConditionSequenceOption[K]
WithConditionSequenceErrorMode sets the ErrorMode of a ConditionSequence
func WithLogicOperation ¶ added in v0.91.0
func WithLogicOperation[K any](logicOp LogicOperation) ConditionSequenceOption[K]
WithLogicOperation sets the LogicOperation of a ConditionSequence When setting AND the conditions will be ANDed together. When setting OR the conditions will be ORed together.
type CreateFunctionFunc ¶ added in v0.77.0
type CreateFunctionFunc[K any] func(fCtx FunctionContext, args Arguments) (ExprFunc[K], error)
type DurationGetter ¶ added in v0.84.0
type DurationGetter[K any] interface { // Get retrieves a time.Duration value. Get(ctx context.Context, tCtx K) (time.Duration, error) }
DurationGetter is a Getter that must return a time.Duration.
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 FunctionGetter ¶ added in v0.83.0
type FunctionGetter[K any] interface { // Get returns a function as an Expr[K] built with the provided Arguments Get(args Arguments) (Expr[K], error) }
FunctionGetter uses a function factory to return an instantiated function as an Expr.
type GetSetter ¶
GetSetter is an interface that combines the Getter and Setter interfaces. It should be used to represent the ability to both get and set a value.
type Getter ¶
type Getter[K any] interface { // Get retrieves a value of type 'Any' and returns an error if there are any issues during retrieval. Get(ctx context.Context, tCtx K) (any, error) }
Getter resolves a value at runtime without performing any type checking on the value that is returned.
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 Key ¶ added in v0.77.0
type Key[K any] interface { // String returns a pointer to the Key's string value. // If the Key does not have a string value the returned value is nil. // If Key experiences an error retrieving the value it is returned. String(context.Context, K) (*string, error) // Int returns a pointer to the Key's int value. // If the Key does not have a int value the returned value is nil. // If Key experiences an error retrieving the value it is returned. Int(context.Context, K) (*int64, error) }
Key represents a chain of keys in an OTTL statement, such as `attributes["foo"]["bar"]`. A Key has a String or Int, and potentially the next Key. If the path in the OTTL statement contains multiple keys, then the Key will have a pointer to the next Key.
type LogicOperation ¶ added in v0.91.0
type LogicOperation string
const ( And LogicOperation = "and" Or LogicOperation = "or" )
func (*LogicOperation) UnmarshalText ¶ added in v0.91.0
func (l *LogicOperation) UnmarshalText(text []byte) error
type Option ¶ added in v0.70.0
func WithEnumParser ¶ added in v0.70.0
func WithEnumParser[K any](parser EnumParser) Option[K]
type Optional ¶ added in v0.86.0
type Optional[T any] struct { // contains filtered or unexported fields }
func NewTestingOptional ¶ added in v0.86.0
Allows creating an Optional with a value already populated for use in testing OTTL functions.
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 }
Parser provides the means to parse OTTL StatementSequence and Conditions given a specific set of functions, a PathExpressionParser, and an EnumParser.
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]) ParseCondition ¶ added in v0.90.0
ParseCondition parses a single string condition into a Condition objects ready for execution. Returns an Condition and a nil error on successful parsing. If parsing fails, returns nil and an error.
func (*Parser[K]) ParseConditions ¶ added in v0.90.0
ParseConditions parses string conditions into a Condition slice ready for execution. Returns a slice of Condition and a nil error on successful parsing. If parsing fails, returns nil and an error containing each error per failed condition.
func (*Parser[K]) ParseStatement ¶ added in v0.72.0
ParseStatement parses a single string statement into a Statement struct ready for execution. Returns a Statement and a nil error on successful parsing. If parsing fails, returns nil and an error.
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 nil and a joined error containing each error per failed statement.
type Path ¶
type Path[K any] interface { // Name is the name of this segment of the path. Name() string // Next provides the next path segment for this Path. // Will return nil if there is no next path. Next() Path[K] // Keys provides the Keys for this Path. // Will return nil if there are no Keys. Keys() []Key[K] // String returns a string representation of this Path and the next Paths String() string }
Path represents a chain of path parts in an OTTL statement, such as `body.string`. A Path has a name, and potentially a set of keys. If the path in the OTTL statement contains multiple parts (separated by a dot (`.`)), then the Path will have a pointer to the next Path.
type Setter ¶
type Setter[K any] interface { // Set sets a value of type 'Any' and returns an error if there are any issues during the setting process. Set(ctx context.Context, tCtx K, val any) error }
Setter allows setting an untyped value on a predefined field within some data at runtime.
type StandardBoolGetter ¶ added in v0.89.0
StandardBoolGetter is a basic implementation of BoolGetter
type StandardBoolLikeGetter ¶ added in v0.89.0
type StandardDurationGetter ¶ added in v0.84.0
StandardDurationGetter is a basic implementation of DurationGetter
type StandardFloatGetter ¶ added in v0.79.0
StandardFloatGetter is a basic implementation of FloatGetter
type StandardFloatLikeGetter ¶ added in v0.78.0
type StandardFunctionGetter ¶ added in v0.83.0
type StandardFunctionGetter[K any] struct { FCtx FunctionContext Fact Factory[K] }
StandardFunctionGetter is a basic implementation of FunctionGetter.
func (StandardFunctionGetter[K]) Get ¶ added in v0.83.0
func (g StandardFunctionGetter[K]) Get(args Arguments) (Expr[K], error)
Get takes an Arguments struct containing arguments the caller wants passed to the function and instantiates the function with those arguments. If there is a mismatch between the function's signature and the arguments the caller wants to pass to the function, an error is returned.
type StandardGetSetter ¶
type StandardGetSetter[K any] struct { Getter func(ctx context.Context, tCtx K) (any, error) Setter func(ctx context.Context, tCtx K, val any) error }
type StandardIntGetter ¶ added in v0.79.0
StandardIntGetter is a basic implementation of IntGetter
type StandardIntLikeGetter ¶ added in v0.78.0
type StandardPMapGetter ¶ added in v0.79.0
StandardPMapGetter is a basic implementation of PMapGetter
type StandardStringGetter ¶ added in v0.79.0
StandardStringGetter is a basic implementation of StringGetter
type StandardStringLikeGetter ¶ added in v0.75.0
type StandardTimeGetter ¶ added in v0.85.0
StandardTimeGetter is a basic implementation of TimeGetter
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 StatementSequence ¶ added in v0.91.0
type StatementSequence[K any] struct { // contains filtered or unexported fields }
StatementSequence represents a list of statements that will be executed sequentially for a TransformContext and will handle errors based on an ErrorMode.
func NewStatementSequence ¶ added in v0.91.0
func NewStatementSequence[K any](statements []*Statement[K], telemetrySettings component.TelemetrySettings, options ...StatementSequenceOption[K]) StatementSequence[K]
NewStatementSequence creates a new StatementSequence with the provided Statement slice and component.TelemetrySettings. The default ErrorMode is `Propagate`. You may also augment the StatementSequence with a slice of StatementSequenceOption.
func (*StatementSequence[K]) Execute ¶ added in v0.91.0
func (s *StatementSequence[K]) Execute(ctx context.Context, tCtx K) error
Execute is a function that will execute all the statements in the StatementSequence list. When the ErrorMode of the StatementSequence is `propagate`, errors cause the execution to halt and the error is returned. When the ErrorMode of the StatementSequence is `ignore`, errors are logged and execution continues to the next statement. When the ErrorMode of the StatementSequence is `silent`, errors are not logged and execution continues to the next statement.
type StatementSequenceOption ¶ added in v0.91.0
type StatementSequenceOption[K any] func(*StatementSequence[K])
func WithStatementSequenceErrorMode ¶ added in v0.91.0
func WithStatementSequenceErrorMode[K any](errorMode ErrorMode) StatementSequenceOption[K]
WithStatementSequenceErrorMode sets the ErrorMode of a StatementSequence
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.