Skip to content

[chore] [scraperhelper] Thread context and error through scrapeFunc#15152

Open
axw wants to merge 2 commits intoopen-telemetry:mainfrom
axw:scrapercontroller-ctx-error
Open

[chore] [scraperhelper] Thread context and error through scrapeFunc#15152
axw wants to merge 2 commits intoopen-telemetry:mainfrom
axw:scrapercontroller-ctx-error

Conversation

@axw
Copy link
Copy Markdown
Contributor

@axw axw commented Apr 20, 2026

Description

Change the scraper controller's scrapeFunc signature to accept a context and return an error. This is preparation for scraper controller extensions (#12449).

NewController wraps the user-supplied scrapeFunc to apply Timeout to the incoming context when non-zero, so scrapeMetrics/scrapeLogs/ scrapeProfiles no longer build their own context, and WithScrapeContext is removed.

Scraper and consumer errors are now returned. The timer path discards the returned error, preserving existing behavior.

Assisted-by: Claude Opus 4.7

Link to tracking issue

Relates to #12449

Testing

Unit tests updated

Documentation

N/A

Change the controller's scrapeFunc signature to accept a context and
return an error. The timer path continues to pass context.Background()
and discard the returned error, preserving existing behavior.

NewController wraps the user-supplied scrapeFunc to apply Timeout to
the incoming context when non-zero, so scrapeMetrics/scrapeLogs/
scrapeProfiles no longer build their own context. They also now
aggregate scraper and consume errors via errors.Join and return them.

This is preparatory refactoring for extension-triggered scrapes
(open-telemetry#12449), where the extension-supplied context and error return
become meaningful.

WithScrapeContext is removed; the wrapper in NewController subsumes it.

Assisted-by: Claude Opus 4.7
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.31%. Comparing base (22a5e61) to head (11c5084).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15152      +/-   ##
==========================================
- Coverage   91.31%   91.31%   -0.01%     
==========================================
  Files         699      699              
  Lines       44939    44951      +12     
==========================================
+ Hits        41036    41045       +9     
- Misses       2759     2761       +2     
- Partials     1144     1145       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@axw axw marked this pull request as ready for review April 20, 2026 03:58
@axw axw requested a review from a team as a code owner April 20, 2026 03:58
@axw axw requested a review from TylerHelmuth April 20, 2026 03:58
Comment thread scraper/scraperhelper/internal/controller/controller.go Outdated
Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
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.

4 participants