Skip to content

docs(time): Steer new measurements at the io.sentry.time clock APIs - #6088

Open
runningcode wants to merge 3 commits into
mainfrom
no/docs-clock-apis
Open

runningcode wants to merge 3 commits into
mainfrom
no/docs-clock-apis

Conversation

@runningcode

@runningcode runningcode commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Documentation only, no behavior change.

  • AGENTS.md gets a "Measuring Time" section: new code that reads a clock uses io.sentry.time, picks the type by what the number is for, and gets the clock from options.getEpochClock() or options.getMonotonicTicker().
  • The getInstance() methods on JavaMonotonicTicker, SystemEpochClock and AndroidMonotonicTicker now point callers at those accessors.

💡 Motivation and Context

io.sentry.time landed in #6028, #6045 and #6030, but nothing says how to use it. The easy mistake is JavaMonotonicTicker.getInstance() on Android: it works, but stops counting during device suspend, so intervals that span a deep sleep come out short. Most existing clock reads still use the old APIs, so the nearest example is usually the wrong one to copy.

💚 How did you test it?

Docs only.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Moving existing call sites onto io.sentry.time is the rest of the clock series and stays out of this PR.

#skip-changelog

@sentry

sentry Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.63.0 (1) release

⚙️ sentry-android Build Distribution Settings

Document on each singleton clock's getInstance() that callers should read
the ticker or wall clock off the options object instead, so they get the
per-platform implementation rather than pinning themselves to one. Calling
JavaMonotonicTicker.getInstance() on Android is the trap worth naming: it
stops counting through a device suspend, so intervals spanning a deep sleep
come out short.

Add an AGENTS.md section so new measurement code reaches for io.sentry.time
rather than DateUtils.getCurrentDateTime() or a SentryDateProvider, picks the
abstraction by what the number is for, and treats adding a new abstraction as
a deliberate step rather than a way around an awkward call site.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
runningcode and others added 2 commits November 6, 2026 13:03
Name the legacy clock interfaces instead of listing their
implementations, which also covers ICurrentDateProvider. Drop the
table's notes column and the history of why the old types remain, and
cut the two rules to a sentence each. The getInstance() Javadoc already
carries the detail where callers see it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the paragraph on when getInstance() may still be called directly.
Only the options accessors and test support do, so it restated the
code. Keep the one reason that matters: JavaMonotonicTicker stops
counting while an Android device is suspended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode marked this pull request as ready for review November 6, 2026 12:09
@runningcode
runningcode requested review from a team and adinauer as code owners November 6, 2026 12:09
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 6, 2026 12:09
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants