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

scrape.Manager: Remove initial scrape delay #14073

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lovromazgon
Copy link

This simple change ensures that the initial scrape can be started without the 5 second delay. A nice side-effect is that tests in that package now complete 15 seconds faster.

Background: I'm working on a small CLI tool that embeds Prometheus and allows you to scrape and visualize metrics ad-hoc. The UX suffers because of the initial 5 second delay.

Signed-off-by: Lovro Mažgon <lovro.mazgon@gmail.com>
Signed-off-by: Lovro Mažgon <lovro.mazgon@gmail.com>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I agree we can remove the initial delays. I was trying to achieve similar in #12687 but it got deprioritized.

However, it feels something is a bit off with this change, especially around tests (even before your change?).

The main issue is that with disabled reloader logic, do we have have update tests that actually tests updates with reloading and it's throttling mechanism? Essentially it feels TestManagerTargetsUpdates now tests some non production flows which essentially reduces our test coverage. I was also confused by reloader disable option (not mention in your PR desc).

Otherwise, I think I like the reloader change, but I would love to have test for it (:

image

NOTE: There is a consequence of Prometheus creating scrape loops for likely not-up-to-date discovery information on start, but I think that's fine.

The tests and optional removal of reloading feels wrong.. do you have time to step back a bit and check what Update related tests around scrape manager Run would make sense WHILE trying to not turn off important parts. Feel free to change the current tests, those are not perfect 🤗

@lovromazgon
Copy link
Author

lovromazgon commented May 13, 2024

Thanks for the quick response @bwplotka! I'll see if I can get some time to have a closer look at the tests and properly test throttling. Although, at the first look, I'm not sure if we can test it without disabling the reloader, at least with the way the signalling happens right now. The problem is that the reloader goroutine is reading from the same channel that Run is writing to, so if the test wants to read from the same channel the receiver will be randomly chosen. So either the reloader can't be running, or we need to change the signalling in a way that we can consistently listen or intercept it in tests.

@@ -147,16 +150,16 @@ func (m *Manager) reloader() {
defer ticker.Stop()

for {
select {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate what exactly is your concern?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants