Title: Move the performance collector's sampling loop off java.util.Timer · Issue #6584 · getsentry/sentry-java · GitHub
Open Graph Title: Move the performance collector's sampling loop off java.util.Timer · Issue #6584 · getsentry/sentry-java
X Title: Move the performance collector's sampling loop off java.util.Timer · Issue #6584 · getsentry/sentry-java
Description: DefaultCompositePerformanceCollector samples CPU and memory every 100ms on a java.util.Timer. It is the last java.util.Timer in the SDK. Timer schedules on the wall clock. After a backward clock step it stops sampling until the clock cat...
Open Graph Description: DefaultCompositePerformanceCollector samples CPU and memory every 100ms on a java.util.Timer. It is the last java.util.Timer in the SDK. Timer schedules on the wall clock. After a backward clock st...
X Description: DefaultCompositePerformanceCollector samples CPU and memory every 100ms on a java.util.Timer. It is the last java.util.Timer in the SDK. Timer schedules on the wall clock. After a backward clock st...
Opengraph URL: https://github.com/getsentry/sentry-java/issues/6584
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Move the performance collector's sampling loop off java.util.Timer","articleBody":"`DefaultCompositePerformanceCollector` samples CPU and memory every 100ms on a `java.util.Timer`. It is the last `java.util.Timer` in the SDK.\n\n`Timer` schedules on the wall clock. After a backward clock step it stops sampling until the clock catches back up, so transactions and profiles get no CPU or memory data for that stretch. The same task runs the 30s collection-budget check, so that check stalls too.\n\n## Fix\n\nRun the loop on `options.getTimerExecutorService()`, which schedules on `System.nanoTime()`. `ISentryExecutorService` only has a one-shot `schedule()`, so the task reschedules itself after each run. That is a fixed delay, the same as today's `Timer.schedule(task, delay, period)`.\n\n## Why main\n\nOnly the scheduling changes. Every sample is stamped and computed the same way as today, so no metric, duration or API changes.\n\n## Prior work\n\n* #5816 ([JAVA-653](https://linear.app/getsentry/issue/JAVA-653/reduce-number-of-threads-created-and-used-by-the-sdk)) made this exact change to save a thread. It was closed without review. Its generation counter, which stops an in-flight run from rescheduling itself after `close()`, is worth reusing.\n* The 30s budget fix in the same class (#6101) is only on `9.x.x`. Expect a small conflict the next time main is merged into `9.x.x`.\n\n## Done when\n\n* `DefaultCompositePerformanceCollector` no longer uses `java.util.Timer`.\n* A run that stops the last transaction doesn't reschedule itself.\n* Tests drive the loop through a fake executor instead of mocking `Timer`.\n\n\u003cdetails>\u003csummary>Agent notes\u003c/summary>\n\nVerified on `main` at `812682636b` (2026-11-12).\n\n* `DefaultCompositePerformanceCollector.java:22` (`timer` field), `:92` (`new Timer(true)`), `:95-107` (one-shot `setup()` task), `:110-144` (100ms sampling task, `TRANSACTION_COLLECTION_INTERVAL_MILLIS`), `:205` (`timer.cancel()`).\n* `ISentryExecutorService` has `submit`, `schedule(Runnable, delayMillis)`, `close`, `isClosed`. No periodic API.\n* `SentryTracer` already uses `getTimerExecutorService().schedule(...)` for its idle and deadline timeouts. Copy that pattern.\n* On `9.x.x`, #6101 added a per-`CompositeData` `Deadline` on `options.getMonotonicTicker()` for the 30s budget.\n* Audit source: getsentry/sentry-java#5530 §C6 / getsentry/sentry-java#5582.\n\n\u003c/details>","author":{"url":"https://github.com/runningcode","@type":"Person","name":"runningcode"},"datePublished":"2026-11-12T08:18:34Z","url":"https://github.com/getsentry/sentry-java/issues/6584"}
| 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:6dfd02cf-835c-e622-b3da-04d3ac9b1dc9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3DE:3A5098:299C23:3A4538:6B04756A |
| html-safe-nonce | c2f8fe82a5713362c205798c8a891b3ce7f646a88ee41f86d5fb253a47822b80 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0RFOjNBNTA5ODoyOTlDMjM6M0E0NTM4OjZCMDQ3NTZBIiwidmlzaXRvcl9pZCI6Ijc5MTM1NTY3NDg4MTUwNzA1NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bf1f4ecf1deb249e67e3784af58f974b2eff49142ac30af816d7fef29da78454 |
| hovercard-subject-tag | issue:6345776470 |
| 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/6584/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4358daeb6dfd4ece862d0c67ebc286369f798ebaa73a1cca82df10bbb16fd347/getsentry/sentry-java/issues/6584 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4358daeb6dfd4ece862d0c67ebc286369f798ebaa73a1cca82df10bbb16fd347/getsentry/sentry-java/issues/6584 |
| og:image:alt | DefaultCompositePerformanceCollector samples CPU and memory every 100ms on a java.util.Timer. It is the last java.util.Timer in the SDK. Timer schedules on the wall clock. After a backward clock st... |
| 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 | 9c099f1b85def81ca352464c276510dfef32deaf3c305404e65b8d270284a58b |
| 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 | cf73f57448d52b3a7b619195e182b33d3b3454ca |
| 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