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

Remove Pyroscope scrape loops for no longer active targets #1833

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Main (unreleased)

- Fixed a bug in `import.git` which caused a `"non-fast-forward update"` error message. (@ptodev)

- `pyroscope.scrape` no longer tries to scrape endpoints which are not active targets anymore. (@wildum @mattdurham @dehaansa @ptodev)

### Other changes

- Small fix in UI stylesheet to fit more content into visible table area. (@defanator)
Expand Down
8 changes: 8 additions & 0 deletions internal/component/pyroscope/scrape/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ func (m *Manager) reload() {
wg.Done()
}(m.targetsGroups[setName], groups)
}

for tgName, sp := range m.targetsGroups {
if _, ok := m.targetSets[tgName]; !ok {
sp.stop()
delete(m.targetsGroups, tgName)
}
}

wg.Wait()
}

Expand Down
5 changes: 5 additions & 0 deletions internal/component/pyroscope/scrape/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import (
"github.com/prometheus/prometheus/discovery/targetgroup"
"github.com/prometheus/prometheus/model/labels"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func TestManager(t *testing.T) {
defer goleak.VerifyNone(t, goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))

reloadInterval = time.Millisecond

m := NewManager(Options{}, pyroscope.AppendableFunc(func(ctx context.Context, labels labels.Labels, samples []*pyroscope.RawSample) error {
Expand Down Expand Up @@ -62,6 +65,8 @@ func TestManager(t *testing.T) {
return len(m.TargetsActive()["group2"]) == 10
}, time.Second, 10*time.Millisecond)

require.Equal(t, 1, len(m.targetsGroups))

for _, ts := range m.targetsGroups {
require.Equal(t, 1*time.Second, ts.config.ScrapeInterval)
}
Expand Down
Loading