-
Notifications
You must be signed in to change notification settings - Fork 5.7k
feat(agent): Add debounce for watch events #17048
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
Conversation
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
@neelayu Could you please rebase your branch on top of |
Co-authored-by: skartikey <1942366+skartikey@users.noreply.github.com>
Yes. I think I added it to check if tests were passing or not. Rebased now |
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.
@neelayu Nice work!
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.
Thanks @neelayu!
Thank you @skartikey |
Summary
This PR implements a debounce mechanism for configuration file watching that batches multiple file changes into a single reload operation.
Changes Made
--watch-debounce-interval
CLI flag to configure the debounce duration (default: 0s for backward compatibility)watchLocalConfig()
function that:SIGHUP
) after the timer expires without interruptionreloadPending
flag to prevent unnecessary operationsBehavior Change
Usage Example
# Enable debouncing with 5-second wait period telegraf --config-directory /configs --watch-config=notify --watch-debounce-interval=5s
Checklist
Related issues
resolves #17047
Essentially, the config watcher will wait for 10 seconds after the last change to the config directory before reloading the config. This is useful when you have multiple files in a directory and you want to avoid reloading the config multiple times if they are changed in quick succession.