Title: Breaking clock changes for v9: span timing and ICurrentDateProvider removal · Issue #6506 · getsentry/sentry-java · GitHub
Open Graph Title: Breaking clock changes for v9: span timing and ICurrentDateProvider removal · Issue #6506 · getsentry/sentry-java
X Title: Breaking clock changes for v9: span timing and ICurrentDateProvider removal · Issue #6506 · getsentry/sentry-java
Description: The project plan holds back every breaking clock change until v9. No other open issue in this project tracks those changes. This one does. Each item below is breaking. It either changes a critical customer metric or breaks the public API...
Open Graph Description: The project plan holds back every breaking clock change until v9. No other open issue in this project tracks those changes. This one does. Each item below is breaking. It either changes a critical ...
X Description: The project plan holds back every breaking clock change until v9. No other open issue in this project tracks those changes. This one does. Each item below is breaking. It either changes a critical ...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/6506
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Breaking clock changes for v9: span timing and ICurrentDateProvider removal","articleBody":"The project plan holds back every breaking clock change until v9. No other open issue in this project tracks those changes. This one does.\n\nEach item below is breaking. It either changes a critical customer metric or breaks the public API.\n\n## 1. Span timing on one `AnchoredClock` per transaction\n\nToday each span reads the wall clock for its own start (`Span` calls `options.getDateProvider().now()`). Its end is that start plus a `System.nanoTime()` difference. So the starts of two spans are two separate wall-clock readings. If the wall clock steps between them, a child span can start before its parent.\n\nThe fix is the design that #6045 shipped as API only. Create one `AnchoredClock` per transaction in `SentryTracer`, and project every span timestamp from it. Nothing calls `AnchoredClock` yet.\n\nWhy it's breaking:\n\n* **Durations start counting deep sleep on Android.** The ticker there is `CLOCK_BOOTTIME`. `System.nanoTime()` is `CLOCK_MONOTONIC`, which stops in deep sleep. Any span or transaction that crosses a deep sleep gets longer. This matches iOS, which is a project goal, but it changes span and transaction durations customers chart and alert on.\n* **Child span** `start_timestamp`**s move by less than a millisecond.** Root spans don't change.\n\nTwo more sites move with this:\n\n* `SpanFrameMetricsCollector.toNanoTime()` reads the wall-to-`nanoTime` offset again each time a span finishes (getsentry/sentry-java#5582 §C5). Draft #6098 anchors it once at SDK init. Fold that fix in here instead of landing it on main (decided 2026-11-12), because it changes the slow, frozen and delayed frame counts on app-start spans.\n* `sentry-android-sqlite`'s `DriverSpans.computeNanoStartTimestampForChild()` builds a child's start from its parent's `SentryNanotimeDate` plus `System.nanoTime()`. That is the same anchor, built by hand.\n\n## 2. Decide whether app start follows\n\n`TimeSpan` runs on `SystemClock.uptimeMillis()`, which also stops in deep sleep. It drives the app start, process init, `Application.onCreate`, content provider and activity lifecycle spans.\n\nOpen question: should app start count deep sleep too? getsentry/sentry-java#5752 argued that launches with a Doze in the middle don't reflect what users actually experience. If app start does switch, it's breaking twice:\n\n* **Metric:** a launch where the device sleeps before the first frame would include the sleep instead of leaving it out, so app-start p95/p99 go up. getsentry/sentry-java#5752 was closed without an SDK change, because these launches are filtered out in the dashboard instead.\n* **API:** `TimeSpan` is in `sentry-android-core.api`. Its methods are named for uptime (`setStartedAt(uptimeMs)`, `getStartUptimeMs()`), and `InternalSentrySdk` serializes it for the hybrid SDKs.\n\ngetsentry/sentry-java#6104's `AndroidEnvelopeCache` call site doesn't depend on this decision. It can take its own boottime reading at SDK init.\n\n## 3. Remove `ICurrentDateProvider`\n\n* `ICurrentDateProvider` and `CurrentDateProvider` are `@ApiStatus.Internal` but listed in `sentry.api`. Neither is deprecated yet.\n* The public `ReplayIntegration` constructors take an `ICurrentDateProvider`. The sentry-dart Android plugin calls the four-argument constructor with `CurrentDateProvider.getInstance()`, so removing it breaks Flutter. Coordinate the change with sentry-dart.\n* `AndroidCurrentDateProvider` is internal and not in the `.api` file (deprecated by getsentry/sentry-java#6102). Delete it once getsentry/sentry-java#6104 has moved its callers.\n* `RateLimiter(ICurrentDateProvider, SentryOptions)` is public API too (`sentry.api`). Remove it along with the interface.\n* Remove the members that getsentry/sentry-java#6586 deprecates on main.\n\n## Other v9 clock tickets\n\n* getsentry/sentry-java#6585: end a backgrounded session when its timeout ran out, not when the device wakes.\n* getsentry/sentry-java#5580: session `seq` and the `Math.abs` session duration.\n\n## Done when\n\n* Spans and transactions take their timestamps from one `AnchoredClock` per transaction.\n* The app-start decision is made, and either implemented or explicitly deferred.\n* `ICurrentDateProvider` is gone from `sentry.api`, and sentry-dart has been updated.\n* The v9 changelog lists each change.\n\n\u003cdetails>\u003csummary>Agent notes\u003c/summary>\n\nVerified on `main` at `1b8668ae2b` (2026-11-06).\n\n* Span start: `sentry/src/main/java/io/sentry/Span.java:68`, `:86`. Span end: `SentryNanotimeDate.laterDateNanosTimestampByDiff`, serialized in `protocol/SentrySpan.java:73-75` and `protocol/SentryTransaction.java:62-68`.\n* Android date provider: `SentryAndroidDateProvider` → `SentryNanotimeDate` (`System.currentTimeMillis()` + `System.nanoTime()`).\n* Ticker: `AndroidMonotonicTicker.tickNanos()` = `SystemClock.elapsedRealtimeNanos()`. Epoch: `SentryOptions.getEpochClock()`.\n* `AnchoredClock` lives in `sentry/src/main/java/io/sentry/time/AnchoredClock.java`. Nothing outside `io.sentry.time` uses it.\n* Constraint for item 1: `Choreographer` frame timestamps are on `CLOCK_MONOTONIC`. `SpanFrameMetricsCollector` has to convert between the two clocks instead of subtracting across them.\n* `TimeSpan`: `sentry-android-core/src/main/java/io/sentry/android/core/performance/TimeSpan.java`. Serialized for hybrid SDKs in `InternalSentrySdk.java:366-370`.\n* sentry-dart caller: `packages/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt`, around line 293.\n* `SpanFrameMetricsCollector.java:317-330` (`toNanoTime`). #6098 is the draft fix.\n* `DriverSpans.kt:112-116` (`computeNanoStartTimestampForChild`).\n* `RateLimiter` public constructor: `sentry/api/sentry.api:7832`.\n* The three items above were checked on `main` at `812682636b` (2026-11-12).\n\n\u003c/details>","author":{"url":"https://github.com/runningcode","@type":"Person","name":"runningcode"},"datePublished":"2026-11-06T14:51:26Z","url":"https://github.com/getsentry/sentry-java/issues/6506"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b4264d4d-158b-277d-bb03-518e236c1365 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA9E:3C4279:1DA194:2A0C18:6B046869 |
| html-safe-nonce | f70b57149eea4bfd51802dc96de5cbb3dbb973d035fd72eb8d59a11b9dc015eb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTlFOjNDNDI3OToxREExOTQ6MkEwQzE4OjZCMDQ2ODY5IiwidmlzaXRvcl9pZCI6IjY4Mjg2NzQzOTI4MDg3NTYyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7d7ea6db6187acdabbd8e78a29400d47c9b1df552058fa5a4a0a9924156734ab |
| hovercard-subject-tag | issue:6244860051 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-java/6506/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a4477062e305b39545480f070b935ca95c439c00d2ff5fac7f06daba84e4d696/getsentry/sentry-java/issues/6506 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a4477062e305b39545480f070b935ca95c439c00d2ff5fac7f06daba84e4d696/getsentry/sentry-java/issues/6506 |
| og:image:alt | The project plan holds back every breaking clock change until v9. No other open issue in this project tracks those changes. This one does. Each item below is breaking. It either changes a critical ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | runningcode |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-java git https://github.com/getsentry/sentry-java.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3368190 |
| octolytics-dimension-repository_nwo | getsentry/sentry-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3368190 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width