Repository navigation
ref(core): Sample performance data on the timer executor (JAVA-837) - #6589
Draft
runningcode wants to merge 1 commit into
Draft
runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
DefaultCompositePerformanceCollector sampled CPU and memory every 100ms on a java.util.Timer, the last one in the SDK. Timer schedules on the wall clock, so a backward clock step stopped sampling, and the 30s collection budget check that runs in the same task, until the clock caught back up. The loop now runs on options.getTimerExecutorService(), which schedules on System.nanoTime(). The executor only has one-shot schedule(), so each run reschedules itself. A generation counter, bumped in close(), stops a run that is already in flight from rescheduling a cancelled chain. Based on #5816. Fixes JAVA-837 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
9 tasks done
This branch has not been deployed
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
DefaultCompositePerformanceCollectorsampled CPU and memory every 100ms on ajava.util.Timer, the lastjava.util.Timerin the SDK.Timerschedules on the wall clock. After a backward clock step it stopped sampling until the clock caught back up, so transactions and profiles got no CPU or memory data for that stretch. The 30s collection-budget check runs in the same task, so it stalled too.The loop now runs on
options.getTimerExecutorService(), which schedules onSystem.nanoTime(), the same executorSentryTraceruses for its idle and deadline timeouts:ISentryExecutorServiceonly has a one-shotschedule(), so each run reschedules itself after 100ms. That is a fixed delay, the same as the oldTimer.schedule(task, delay, period).close()undertimerLock, stops a run that is already in flight from rescheduling a chain that was cancelled. That matters when the run itself times out the last transaction and so closes the collector.close()cancels the pending run withFuture.cancel(false), likeTimer.cancel()did.RejectedExecutionException(thrown once the executor is shut down), and logs aftertimerLockis released.Only scheduling changes. Every sample is stamped and computed as before, so no metric, duration or API changes. As a side effect, the collector no longer creates and destroys a thread for each burst of transactions.
💡 Motivation and Context
This is based on #5816 (JAVA-653), which made the same change to save a thread and was closed without review.
The 30s budget fix in this class (#6101) is only on
9.x.x. Expect a small conflict the next timemainis merged into9.x.x.💚 How did you test it?
DefaultCompositePerformanceCollectorTestnow runs on a real executor wrapped to record schedule delays, instead of a spiedTimer.collector times out after 30 secondsfails without the generation counter: the run that stops the last transaction would reschedule itself. All 20 tests in that class and 120 inSentryTracerTestpass.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None for this class on
main.#skip-changelog
🤖 Generated with Claude Code