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

Improve plugin code guide #12202

Closed
reimda opened this issue Nov 8, 2022 · 2 comments · Fixed by #15356
Closed

Improve plugin code guide #12202

reimda opened this issue Nov 8, 2022 · 2 comments · Fixed by #15356
Labels
docs Issues related to Telegraf documentation and configuration descriptions

Comments

@reimda
Copy link
Contributor

reimda commented Nov 8, 2022

Add guidance on when plugins should connect to external services and whether failures to connect should prevent telegraf from starting up.

Typically service inputs and outputs need to make a connection over the network and reuse that connection for a long time. In these cases when the plugin can't make the connection it needs, the default behavior should be to cause telegraf to fail to start. ServiceInput should return error from Start method and Output should return error from Connect method. This is the default in order to prevent typos in connection settings from going unnoticed.

Plugins can have a setting that allow required connections to be made later. The user must choose deferred connection by changing a setting. In this case there is no protection against typos and connection errors won't prevent telegraf from starting.

If a plugin connects to a local socket or reads from a file or gets information from the operating system, they don't need to require the connection at Start/Connect

@Hipska Hipska added the docs Issues related to Telegraf documentation and configuration descriptions label Nov 8, 2022
@zak-pawel
Copy link
Collaborator

@reimda I'm not sure if this guide should be limited to ServiceInput plugins only. I would take into consideration also "normal" Input plugins (with Init() error function).

You wrote "If a plugin connects to a local socket ... they don't need to require the connection at Start/Connect". But can they (with proper setting that allow required connections to be made later of course)?

@Hipska
Copy link
Contributor

Hipska commented Nov 9, 2022

They don't need to require it, but indeed, they can do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues related to Telegraf documentation and configuration descriptions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants