-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pkg/ottl] add ValueExpression
to support extraction of values from the signal context
#36883
base: main
Are you sure you want to change the base?
[pkg/ottl] add ValueExpression
to support extraction of values from the signal context
#36883
Conversation
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
ValueExpression
to support extraction of values from the signal context
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me.
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change_logs: [] | |
change_logs: [api] |
Since the target of this feature is component authors, we should mark it as an API change.
func parseValueExpression(raw string) (*value, error) { | ||
parsed, err := valueExpressionParser.ParseString("", raw) | ||
if err != nil { | ||
return nil, fmt.Errorf("condition has invalid syntax: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, fmt.Errorf("condition has invalid syntax: %w", err) | |
return nil, fmt.Errorf("expression has invalid syntax: %w", err) |
component: pkg/ottl | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add value expression parser that enables components using ottl to retrieve values from the context, as well as the result of converter functions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Add value expression parser that enables components using ottl to retrieve values from the context, as well as the result of converter functions | |
note: Add value expression parser that enables components using ottl to retrieve values from the output of an expression |
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subtext: | |
subtext: the expression can be either a literal value, a path value within the context, or the result of a converter and/or a mathematical expression. |
I think the doc you wrote for this is perfect for describing what can be used inside the subtext.
Description
This PR adds a new
ParseValueExpression
method to the OTTL parser which allows users of this package to extract data from the context using OTTLLink to tracking issue
Fixes #35621
Testing
Added unit and e2e tests
Documentation
Added godoc comments for the added methods and types