Skip to content
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

[processor/transform] Report all parsing errors #24245

Merged

Conversation

evan-bradley
Copy link
Contributor

Description:

Follow up from #23840 to report all errors that occur during parsing. The error isn't pretty, but this way users know all syntax errors in their OTTL statements up front.

I played around with trying to format this to make it more readable, but wasn't able to come up with anything that was satisfactory.

Example config and resulting error:

processors:
  transform:
    trace_statements:
      - context: span
        statements: 
        - ParseJSON("...")
        - false
        - set[[]]
    metric_statements:
      - context: datapoint
        statements: 
        - set(attributes, attributes)
        - true
        - set(
Error: invalid configuration: processors::transform: unable to parse OTTL statement "ParseJSON(\"...\")": editor names must start with a lowercase letter but got 'ParseJSON'; unable to parse OTTL statement "0": statement has invalid syntax: 1:1: unexpected token "0"; unable to parse OTTL statement "set[[]]": statement has invalid syntax: 1:4: unexpected token "[" (expected "(" (Value ("," Value)*)? ")" Key*); unable to parse OTTL statement "1": statement has invalid syntax: 1:1: unexpected token "1"; unable to parse OTTL statement "set(": statement has invalid syntax: 1:5: unexpected token "<EOF>" (expected ")" Key*)

I aggregated the errors both in the Config struct and on processor startup, but realistically are highly unlikely to get an error from the parser on startup because we've already validated the statements. I updated it just so we're consistent between validating the config and reporting errors from the OTTL parser.

@crobert-1
Copy link
Member

Failing CI action is just to run make gotidy

@evan-bradley evan-bradley merged commit 9b28f76 into open-telemetry:main Jul 14, 2023
88 checks passed
@github-actions github-actions bot added this to the next release milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/transform Transform processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants