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

feat: Parser plugin restructuring #8791

Merged
merged 51 commits into from
Jan 12, 2022
Merged

Conversation

srebhan
Copy link
Member

@srebhan srebhan commented Feb 3, 2021

Required for all PRs:

  • Associated README.md updated.
  • Has appropriate unit tests.

This PR restructures the parser plugin infrastructure to match those of other plugins (e.g. input, aggregators,...) with a central registry and config definitions (including TOML tags) in the parser code itself. This reliefs new parsers for spraying the code all over the project and allow them to keep all in one place (the parser code).

By using the new infrastructure you get some goodies for free like support of logging via definition of Log telegraf.Logger 'toml:"-"' and internal plugin statistics metrics_parsed and parse_time_ns. We keep backward compatibility so parsers not ported yet are still supported.
This PR currently only converts the CSV parser to the new interface as a PoC and fixes the fallout.

The main benefit is that now, implementing new parser plugins has the same procedure as all other plugins. You write your self-contained parser in a sub-directory below plugins/parsers , add it to plugins/parsers/all/all.go and update the documentation. No need anymore to add TOML exceptions in config or fight with plugins/parsers/registration.go.

Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤝 ✅ CLA has been signed. Thank you!

@srebhan srebhan marked this pull request as draft February 3, 2021 11:01
@helenosheaa helenosheaa added fix pr to fix corresponding bug and removed fix pr to fix corresponding bug labels Feb 4, 2021
@srebhan srebhan added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins labels Feb 7, 2021
@srebhan srebhan marked this pull request as ready for review March 16, 2021 10:41
Copy link
Contributor

@ssoroka ssoroka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall I think it's headed in the right direction. some thoughts:

  • I don't think you can remove parsers.Parsers without breaking backwards compatibility, it's part of the contract we maintain to plugins.
  • I don't feel like giving parsers their own runners makes sense in the way it does for inputs/etc, because they really belong to the plugin using them.
  • FYI there's future parser work related to stream parsers, and supporting multiple parsers per input plugin at some point.

parser.go Show resolved Hide resolved
models/running_parsers.go Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
agent/agent.go Show resolved Hide resolved
parser.go Outdated Show resolved Hide resolved
@srebhan srebhan changed the title Parser plugin restructuring feat: Parser plugin restructuring Nov 20, 2021
@srebhan
Copy link
Member Author

srebhan commented Nov 20, 2021

@sspaink, @reimda, @powersj, @MyaLongmire here is the discussed update. Would love to get your feedback!

@srebhan srebhan requested a review from sspaink November 20, 2021 21:25
@srebhan srebhan force-pushed the parser_restructure branch 3 times, most recently from 12b9a40 to 0c02235 Compare December 3, 2021 09:49
Copy link
Contributor

@sspaink sspaink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I think this looks good.

@sspaink sspaink added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Dec 3, 2021
@etycomputer
Copy link
Contributor

Hi @srebhan,
You have been very busy.
The only suggestion that I can make is to add a new test to the exec input plugin to cover the #10347 scenario.
Cheers

@srebhan srebhan force-pushed the parser_restructure branch from 0c02235 to 8109072 Compare January 12, 2022 14:49
@srebhan srebhan requested review from sspaink and reimda January 12, 2022 15:41
Copy link
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for working on this. It will be nice to switch them all over to the new system and then remove the old compatibility code!

@reimda reimda merged commit 193dc45 into influxdata:master Jan 12, 2022
@srebhan srebhan deleted the parser_restructure branch January 13, 2022 09:38
@srebhan srebhan mentioned this pull request Jan 17, 2022
3 tasks
powersj pushed a commit to powersj/telegraf that referenced this pull request Jan 21, 2022
powersj pushed a commit to powersj/telegraf that referenced this pull request Jan 21, 2022
@srebhan
Copy link
Member Author

srebhan commented Jan 24, 2022

@etycomputer could you please submit a PR adding this as a test-case? Your help would be very much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants