optimize LoadSources to avoid full restart on metric or tag changes #1350
Closed
nadashaban11 wants to merge 1 commit intocybertec-postgresql:masterfrom
Closed
optimize LoadSources to avoid full restart on metric or tag changes #1350nadashaban11 wants to merge 1 commit intocybertec-postgresql:masterfrom
LoadSources to avoid full restart on metric or tag changes #1350nadashaban11 wants to merge 1 commit intocybertec-postgresql:masterfrom
Conversation
Collaborator
|
Thanks for your work. Have you checked #1316? |
Contributor
Author
|
Thanks for pointing that I really have not checked before, but now I found great enhancements. I will close this PR since it conflicts with the new planned architecture. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
current behavior of
pgwatchis to full restart after any update on source. I tried to work on theTODOmentioned inLoadSourcesto optimize that behavior .Fixes
First, I was confused about how to divide full restart but I got the following approach:
1- change requires full restart because connection config changed this includes any change in(connStr, Kind, Group, Name, IsEnabled, IncludePattern, ExcludePattern, or OnlyIfMaster) .
In this case no code changes, exact current code
2- change does not require full restart only update with the new changes that will be caught without forcing to reconnect source this includes any change in metrics or custom tags.
To achieve that I made
IsSameConnectionininternal/sources/types.goto ensure that no full restart required and tested it ininternal/sources/types_test.gointernal/reaper/reaper.goI left current code to do the full restart whenIsSameConnectionreturns falsebut if it true then update all existing metrics and tags with the new updates
expectCancelI replaced it by: removing it from case 1 as it always should be trueexpectedCancelledto detect changed metric to be stoppedBehavior before ( when modifying any thing all produce such the following logs)
Behavior after
1- when modifying connection config
2- when modifying metrics or tags
here I changed Metrics preset
here I changed metric interval
Note
I tried to describe code changes in comments as possible to better understand while I am working and to easy review
AI/automation tools used (leave blank if none):
discussed with gemini which changes can cause full restart
Checklist