[chore] [scraperhelper] Thread context and error through scrapeFunc#15152
Open
axw wants to merge 2 commits intoopen-telemetry:mainfrom
Open
[chore] [scraperhelper] Thread context and error through scrapeFunc#15152axw wants to merge 2 commits intoopen-telemetry:mainfrom
axw wants to merge 2 commits intoopen-telemetry:mainfrom
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
dmathieu
approved these changes
Apr 20, 2026
florianl
approved these changes
Apr 20, 2026
Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
jmacd
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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