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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions scrape/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ type Options struct {
// Optional HTTP client options to use when scraping.
HTTPClientOptions []config_util.HTTPClientOption

// private option for testability.
// private options for testability.
skipOffsetting bool
skipReloader bool
}

// Manager maintains a set of scrape pools and manages start/stop cycles
Expand All @@ -114,7 +115,9 @@ type Manager struct {
// Run receives and saves target set updates and triggers the scraping loops reloading.
// Reloading happens in the background so that it doesn't block receiving targets updates.
func (m *Manager) Run(tsets <-chan map[string][]*targetgroup.Group) error {
go m.reloader()
if !m.opts.skipReloader {
go m.reloader()
}
for {
select {
case ts := <-tsets:
Expand Down Expand Up @@ -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?

case <-m.triggerReload:
m.reload()
case <-m.graceShut:
return
}
select {
case <-m.graceShut:
return
case <-ticker.C:
select {
case <-m.triggerReload:
m.reload()
case <-m.graceShut:
return
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion scrape/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ scrape_configs:
}

func TestManagerTargetsUpdates(t *testing.T) {
opts := Options{}
opts := Options{skipReloader: true}
testRegistry := prometheus.NewRegistry()
m, err := NewManager(&opts, nil, nil, testRegistry)
require.NoError(t, err)
Expand Down