ref(checkin): Measure check-in durations with Stopwatch (JAVA-576) - #6032
Draft
runningcode wants to merge 1 commit into
Draft
ref(checkin): Measure check-in durations with Stopwatch (JAVA-576)#6032runningcode wants to merge 1 commit into
runningcode wants to merge 1 commit into
Conversation
📲 Install BuildsAndroid
|
9 tasks
runningcode
force-pushed
the
no/java-576-checkin-stopwatch
branch
from
September 2, 2026 08:23
de557be to
edd22f0
Compare
runningcode
force-pushed
the
no/java-574-ratelimiter-deadline
branch
from
September 2, 2026 08:23
eb4c4ad to
0a21879
Compare
This was referenced Sep 2, 2026
runningcode
force-pushed
the
no/java-576-checkin-stopwatch
branch
from
September 2, 2026 13:35
edd22f0 to
fef63c7
Compare
runningcode
force-pushed
the
no/java-574-ratelimiter-deadline
branch
from
September 2, 2026 13:35
0a21879 to
074890f
Compare
runningcode
force-pushed
the
no/java-576-checkin-stopwatch
branch
from
September 2, 2026 13:37
fef63c7 to
9829cc8
Compare
runningcode
force-pushed
the
no/java-574-ratelimiter-deadline
branch
2 times, most recently
from
September 3, 2026 15:11
781c864 to
8bb8665
Compare
runningcode
force-pushed
the
no/java-576-checkin-stopwatch
branch
from
September 3, 2026 15:11
9829cc8 to
c11fec4
Compare
All four check-in paths kept a `long startTime = System.nanoTime()` and subtracted it in a finally block: CheckInUtils and the SentryCheckInAdvice in sentry-spring, sentry-spring-jakarta and sentry-spring-7. The clock now comes from the options, so a check-in measures on whatever the SDK measures on: System.nanoTime() on the JVM, unchanged to the bit, and SystemClock.elapsedRealtimeNanos() on Android. A cron job that spans a suspend therefore reports the duration a user would measure rather than the time the CPU happened to be awake, which is what a check-in duration is meant to mean. An uninitialised SDK still reaches a clock: NoOpScopes.getOptions() hands back empty options, whose clock is the JVM one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
runningcode
force-pushed
the
no/java-574-ratelimiter-deadline
branch
from
September 3, 2026 15:41
8bb8665 to
fc85c12
Compare
runningcode
force-pushed
the
no/java-576-checkin-stopwatch
branch
from
September 3, 2026 15:41
c11fec4 to
0d1d4c9
Compare
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.
PR Stack (Clock semantics hardening)
📜 Description
All four check-in paths kept a start tick and subtracted it in a
finally:CheckInUtilsplusSentryCheckInAdviceinsentry-spring,sentry-spring-jakartaandsentry-spring-7.Stacked on #6030 → #6029 → #6028.
💡 Motivation and Context
A check-in
durationis meant to say how long the job took, which is what a cron monitor's alerting thresholds are set against. Reading the clock from the options gives that meaning on both platforms:MonotonicClockthere isSystem.nanoTime(), the same reading the code took before. This is the same arithmetic behind a name.MonotonicClockisSystemClock.elapsedRealtimeNanos(), so a job that spans a suspend reports the duration a user would measure rather than the time the CPU happened to be awake.The Android half is a change to a serialized value, which the rest of this series holds for v9 — so it is called out under Behavioral Changes in the changelog rather than slipped in. It is the correct value for the field, the affected surface is cron check-ins on Android, and deferring it would mean shipping the wrong number for another major just to keep the diff inert.
An uninitialised SDK still reaches a clock:
NoOpScopes.getOptions()returns empty options, whose clock is the JVM one.💚 How did you test it?
No new tests. The conversion is mechanical and the existing check-in tests already assert the emitted
duration; a test thatStopwatch.started(...)measures elapsed time would be testingStopwatchTesta second time. One existingCheckInUtilsTestcase neededscopes.optionsstubbed, now that the clock is read from there..apihas no diff.sentry's check-in tests pass, and all four modules compile.A pre-existing failure you should know about, since it is in the files this PR touches:
SentryCheckInAdviceTestfails locally for me in all three Spring modules — 14 failures,expected:<1> but was:<0>on thecaptureCheckInverifications. I confirmed it is not caused by this change by running the same tests on a cleanorigin/mainworktree: the same failures, with none of this stack applied. It looks like a local environment problem rather than a repo one, but I could not rule that out from here, so CI on this PR is the real check.📝 Checklist
sendDefaultPIIis enabled.