-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Comments
@reimda I'm not sure if this guide should be limited to 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)? |
They don't need to require it, but indeed, they can do it. |
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
The text was updated successfully, but these errors were encountered: