diff --git a/pkg/ottl/parser.go b/pkg/ottl/parser.go index 1afbed76ffa9..890a88c45cc3 100644 --- a/pkg/ottl/parser.go +++ b/pkg/ottl/parser.go @@ -54,6 +54,7 @@ type Parser[K any] struct { type Statement[K any] struct { function Expr[K] condition BoolExpr[K] + origText string } // Execute is a function that will execute the statement's function if the statement's condition is met. @@ -134,6 +135,7 @@ func (p *Parser[K]) ParseStatement(statement string) (*Statement[K], error) { return &Statement[K]{ function: function, condition: expression, + origText: statement, }, nil } @@ -201,10 +203,10 @@ func (s *Statements[K]) Execute(ctx context.Context, tCtx K) error { _, _, err := statement.Execute(ctx, tCtx) if err != nil { if s.errorMode == PropagateError { - err = fmt.Errorf("failed to execute statement: %w", err) + err = fmt.Errorf("failed to execute statement: %v, %w", statement.origText, err) return err } - s.telemetrySettings.Logger.Error("failed to execute statement", zap.Error(err)) + s.telemetrySettings.Logger.Warn("failed to execute statement", zap.Error(err), zap.String("statement", statement.origText)) } } return nil