Skip to content

ref(time): Deprecate the legacy clock APIs (JAVA-839) - #6863

Open
runningcode wants to merge 3 commits into
mainfrom
no/java-839-deprecate-legacy-clocks
Open

runningcode wants to merge 3 commits into
mainfrom
no/java-839-deprecate-legacy-clocks

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Deprecate the legacy clock APIs that io.sentry.time replaced. Nothing moves to the new APIs and nothing is removed here, so behavior doesn't change and the .api files stay the same.

Deprecated Replacement
ICurrentDateProvider.getCurrentTimeMillis() Stopwatch or Deadline for an interval, options.getEpochClock() for an instant
CurrentDateProvider.getInstance() options.getEpochClock()
DateUtils.getCurrentDateTime() options.getEpochClock()
AndroidDateUtils.getCurrentSentryDateTime() options.getDateProvider(), until span timing moves to AnchoredClock (#6506)

@Deprecated goes on these members, not on the types. The Android modules compile at Java 8 with -Werror. There, importing a deprecated type warns, and an import can't carry @SuppressWarnings.

Call sites that still use these suppress the warning on the smallest scope they allow: the local variable where possible, otherwise the method. Each site that a v9 ticket will move also gets a TODO [v9] naming it: JAVA-827 for span timing and ReplayIntegration, and JAVA-573 for LifecycleWatcher. No ticket moves the DateUtils.getCurrentDateTime() callers yet, so those suppressions have no TODO.

SentryDateProvider is not deprecated. It still drives span timestamps, and nothing replaces it until #6506. React Native also builds SentryAndroidDateProvider directly.

💡 Motivation and Context

Step 1.3 of the clock project: give users and the hybrid SDKs at least one release of warnings before v9 removes these APIs (#6506). This replaces the stale #6043.

📝 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.
  • Changelog entry starts with the product it affects, e.g. Session Replay:, Android:, Backend: or Core: (see CONTRIBUTING.md).
  • 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

Remove these members, ICurrentDateProvider and CurrentDateProvider in v9 (#6506 §3), together with sentry-dart, whose Android plugin calls CurrentDateProvider.getInstance().

🤖 Generated with Claude Code

runningcode and others added 2 commits December 4, 2026 16:44
The io.sentry.time APIs replaced these, but nothing marked the old ones,
so new code kept reaching for them. Deprecate them now so the hybrid SDKs
get a release of warnings before v9 removes them.

Deprecated:
- ICurrentDateProvider.getCurrentTimeMillis()
- CurrentDateProvider.getInstance()
- DateUtils.getCurrentDateTime()
- AndroidDateUtils.getCurrentSentryDateTime()

The annotations sit on the members, not the types: the Android modules
compile at Java 8 with -Werror, where importing a deprecated type warns
and an import can't carry @SuppressWarnings. Remaining call sites suppress
the warning on the smallest scope, with a TODO naming the ticket that
moves them where one exists.

Fixes GH-6586
Fixes JAVA-839

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Dec 4, 2026

Copy link
Copy Markdown

JAVA-839

…-legacy-clocks

# Conflicts:
#	sentry-android-core/src/main/java/io/sentry/android/core/internal/util/AndroidCurrentDateProvider.java
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 5d789d9.

The model rated this change low. It was raised to medium because:

  • R7: the model was not confident enough that the change is low

This label is a hint for reviewers, not an approval.

@runningcode
runningcode marked this pull request as ready for review December 4, 2026 15:46
@runningcode
runningcode requested review from a team and adinauer as code owners December 4, 2026 15:46
@runningcode
runningcode requested review from markushi and romtsn and removed request for a team December 4, 2026 15:46
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@sentry

sentry Bot commented Dec 4, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm 👍 A few small items:

  • ReplayIntegration still requires an ICurrentDateProvider in its public constructors, so the "use options.getEpochClock()" advice isn't something sentry-dart can follow. Worth a note in the Javadoc, or a constructor that doesn't take one?
  • At ActivityLifecycleIntegration.java:1138, options is already non-null, so I imagine options.getDateProvider().now() works there instead of the suppression.
  • nit: the two Breadcrumb suppressions could go on the local timestamp instead of the whole method.

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

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate the legacy clock and date-provider APIs

2 participants