-
Notifications
You must be signed in to change notification settings - Fork 3
Remote Version: Add async polling to speed up the scraping /metrics endpoint #102
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
base: main
Are you sure you want to change the base?
Conversation
hansmi
left a comment
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.
Partial review only. Code needs some changes.
|
|
||
| // run executes the periodic polling loop. | ||
| func (c *remoteVersionCollector) run() { | ||
| ticker := time.NewTicker(c.interval) |
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.
Unfortunately this code will keep polling even when there are no metric requests. With the (current) default that's once per minute.
Please restructure such that a new request is issued if the last result is older than a configured interval. That way no "stopping" is necessary either.
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.
I may not understand fully your point. Can you elaborate a bit?
The basic idea is to keep polling the information in the background to speed up the /metrics request and not doing a call each /metric call. The new default is 1h, but can also be set to 1d.
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.
@hansmi Any deeper elaboration for me? Happy to adjust the code here.
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.
I see. Is the long /metrics request a big problem?
Would it be better to introduce a separate endpoint to get the remote version metrics (the result of which could still be reflected in /metrics in a passive manner)? For that endpoint Prometheus can be configured to use a longer timeout plus a longer poll interval.
Don't worry about the code yet.
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.
Another endpoint would also be good, a different polling interval can be configured.
Is the long /metrics request a big problem?
Not in this particular situation. I would like
- to poll the paperless metrics very frequently
- to poll / refresh the remote version only once a day
As not much new versions are getting released.
(the result of which could still be reflected in /metrics in a passive manner)
How would this be reflected in the code?
I see two options:
- This one here with a different timing polling mechanism
- Another
/metrics-remoteendpoint
The additional /metrics-remote is rather uncommon for tooling that exposes metrics.
Let me know how you would like to proceed.
ba77841 to
e4a2606
Compare
e4a2606 to
fb95478
Compare
fb95478 to
fff54a6
Compare
|
I found out, that during startup, i do two initial fetches. With 6ded949 this is now only one |
This PR adds the functionality to not call the remote version endpoint everytime
/metricsis called, but in an async way.The interval can be configured via the
--remote-version-intervalflag.