Skip to content

Commit

Permalink
adapt parser
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
  • Loading branch information
odubajDT committed Dec 11, 2024
1 parent 1b1df6e commit 9541dca
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/ottl/e2e/e2e_test.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
@@ -967,7 +968,7 @@ func Test_e2e_converters(t *testing.T) {
logParser, err := ottllog.NewParser(ottlfuncs.StandardFuncs[ottllog.TransformContext](), settings)
assert.NoError(t, err)
logStatements, err := logParser.ParseStatement(tt.statement)
assert.NoError(t, err)
require.Nil(t, err)

tCtx := constructLogTransformContext()
_, _, _ = logStatements.Execute(context.Background(), tCtx)
10 changes: 8 additions & 2 deletions pkg/ottl/functions.go
Original file line number Diff line number Diff line change
@@ -481,10 +481,16 @@ func (p *Parser[K]) buildArg(argVal value, argType reflect.Type) (any, error) {
case strings.HasPrefix(name, "Setter"):
fallthrough
case strings.HasPrefix(name, "GetSetter"):
var path *path
if argVal.Literal == nil || argVal.Literal.Path == nil {
return nil, fmt.Errorf("must be a path")
if argVal.ExpressionPath == nil {
return nil, fmt.Errorf("must be a path")
}
path = argVal.ExpressionPath
} else {
path = argVal.Literal.Path
}
np, err := p.newPath(argVal.Literal.Path)
np, err := p.newPath(path)
if err != nil {
return nil, err
}

0 comments on commit 9541dca

Please sign in to comment.