Skip to content
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
25 changes: 25 additions & 0 deletions .chloggen/add-metrics-scraper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: pkg/scraperhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Introduce `AddMetricsScraper` to be more explicit than `AddScraper`.

# One or more tracking issues or pull requests related to the change
issues: [14428]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
25 changes: 25 additions & 0 deletions .chloggen/deprecate-add-scraper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
component: pkg/scraperhelper

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate the `AddScraper` method.

# One or more tracking issues or pull requests related to the change
issues: [14428]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
17 changes: 14 additions & 3 deletions scraper/scraperhelper/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,30 @@ func (of optionFunc) apply(e *controllerOptions) {
of(e)
}

// AddScraper configures the scraper.Metrics to be called with the specified options,
// and at the specified collection interval.
// AddMetricsScraper configures the scraper.Metrics to be called with the
// specified options, and at the specified collection interval.
//
// Observability information will be reported, and the scraped metrics
// will be passed to the next consumer.
func AddScraper(t component.Type, sc scraper.Metrics) ControllerOption {
func AddMetricsScraper(t component.Type, sc scraper.Metrics) ControllerOption {
f := scraper.NewFactory(t, nil,
scraper.WithMetrics(func(context.Context, scraper.Settings, component.Config) (scraper.Metrics, error) {
return sc, nil
}, component.StabilityLevelAlpha))
return AddFactoryWithConfig(f, nil)
}

// AddScraper configures the scraper.Metrics to be called with the
// specified options, and at the specified collection interval.
//
// Observability information will be reported, and the scraped metrics
// will be passed to the next consumer.
//
// Deprecated: [0.144.0] Use AddMetricsScraper instead.
func AddScraper(t component.Type, sc scraper.Metrics) ControllerOption {
return AddMetricsScraper(t, sc)
}

// AddFactoryWithConfig configures the scraper.Factory and associated config that
// will be used to create a new scraper. The created scraper will be called with
// the specified options, and at the specified collection interval.
Expand Down
10 changes: 5 additions & 5 deletions scraper/scraperhelper/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func configureMetricOptions(t *testing.T, test scraperTestCase, initializeChs []
scp, err := scraper.NewMetrics(ts.scrapeMetrics, scraperOptions...)
require.NoError(t, err)

metricOptions = append(metricOptions, AddScraper(component.MustNewType("scraper"), scp))
metricOptions = append(metricOptions, AddMetricsScraper(component.MustNewType("scraper"), scp))
}

return metricOptions
Expand Down Expand Up @@ -522,7 +522,7 @@ func TestSingleMetricsScraperPerInterval(t *testing.T) {
cfg,
receivertest.NewNopSettings(receivertest.NopType),
new(consumertest.MetricsSink),
AddScraper(component.MustNewType("scraper"), scp),
AddMetricsScraper(component.MustNewType("scraper"), scp),
WithTickerChannel(tickerCh),
)
require.NoError(t, err)
Expand Down Expand Up @@ -594,7 +594,7 @@ func TestMetricsScraperControllerStartsOnInit(t *testing.T) {
},
receivertest.NewNopSettings(receivertest.NopType),
new(consumertest.MetricsSink),
AddScraper(component.MustNewType("scraper"), scp),
AddMetricsScraper(component.MustNewType("scraper"), scp),
)
require.NoError(t, err, "Must not error when creating scrape controller")

Expand Down Expand Up @@ -669,7 +669,7 @@ func TestMetricsScraperControllerInitialDelay(t *testing.T) {
&cfg,
receivertest.NewNopSettings(receivertest.NopType),
new(consumertest.MetricsSink),
AddScraper(component.MustNewType("scraper"), scp),
AddMetricsScraper(component.MustNewType("scraper"), scp),
)
require.NoError(t, err, "Must not error when creating receiver")

Expand Down Expand Up @@ -733,7 +733,7 @@ func TestMetricsScraperShutdownBeforeScrapeCanStart(t *testing.T) {
&cfg,
receivertest.NewNopSettings(receivertest.NopType),
new(consumertest.MetricsSink),
AddScraper(component.MustNewType("scraper"), scp),
AddMetricsScraper(component.MustNewType("scraper"), scp),
)
require.NoError(t, err, "Must not error when creating receiver")
require.NoError(t, r.Start(context.Background(), componenttest.NewNopHost()))
Expand Down
Loading