From 8f7dbacc78e0ab50656abc101f1414f8be94c1be Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2026 08:36:32 +0000 Subject: [PATCH 1/2] chore(android): Graduate ANR profiling out of experimental Document AnrProfilingIntegration and anrProfilingSampleRate as stable public API. Co-Authored-By: Markus Hintersteiner --- .../android/core/SentryAndroidOptions.java | 25 +++++++++++++++++++ .../core/anr/AnrProfilingIntegration.java | 7 ++++++ 2 files changed, 32 insertions(+) diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java index 615db97a28d..66a3700d388 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java @@ -277,6 +277,10 @@ public interface BeforeCaptureCallback { */ private final @NotNull SentryScreenshotOptions screenshot = new SentryScreenshotOptions(); + /** + * Sample rate for capturing main-thread stack profiles when a foreground ANR is detected. {@code + * null} disables ANR profiling (default). Values must be between {@code 0.0} and {@code 1.0}. + */ private @Nullable Double anrProfilingSampleRate; private boolean enableAnrFingerprinting = true; @@ -823,10 +827,25 @@ public void setEnableSystemEventBreadcrumbsExtras( return screenshot; } + /** + * Returns the sample rate used when deciding whether to capture a main-thread stack profile for a + * detected foreground ANR. + * + * @return the ANR profiling sample rate, or {@code null} when ANR profiling is disabled + */ public @Nullable Double getAnrProfilingSampleRate() { return anrProfilingSampleRate; } + /** + * Sets the sample rate for capturing main-thread stack profiles when a foreground ANR is + * detected. The profile is attached to the ANR event on the next app start. + * + *

Use {@code null} to disable ANR profiling (default). Values must be between {@code 0.0} and + * {@code 1.0}. + * + * @param anrProfilingSampleRate the sample rate, or {@code null} to disable + */ public void setAnrProfilingSampleRate(final @Nullable Double anrProfilingSampleRate) { if (!SampleRateUtils.isValidSampleRate(anrProfilingSampleRate)) { throw new IllegalArgumentException( @@ -837,6 +856,12 @@ public void setAnrProfilingSampleRate(final @Nullable Double anrProfilingSampleR this.anrProfilingSampleRate = anrProfilingSampleRate; } + /** + * Returns whether ANR profiling is enabled. ANR profiling is enabled when {@link + * #getAnrProfilingSampleRate()} is non-null and greater than {@code 0.0}. + * + * @return {@code true} if ANR profiling is enabled + */ public boolean isAnrProfilingEnabled() { return anrProfilingSampleRate != null && anrProfilingSampleRate > 0; } diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfilingIntegration.java b/sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfilingIntegration.java index 97ec0434249..3cb0bea4b0f 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfilingIntegration.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/anr/AnrProfilingIntegration.java @@ -27,6 +27,13 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; +/** + * Captures main-thread stack profiles while the app is unresponsive and attaches them to ANR events + * on the next app start. + * + *

Enable via {@link SentryAndroidOptions#setAnrProfilingSampleRate(Double)} or the {@code + * io.sentry.anr.profiling.sample-rate} manifest metadata. + */ public class AnrProfilingIntegration implements Integration, Closeable, AppState.AppStateListener, Runnable { From baf97641331765a5f87557753f1c6f63c5edf6db Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 2 Sep 2026 08:37:49 +0000 Subject: [PATCH 2/2] changelog Co-Authored-By: Markus Hintersteiner --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2087ecfce35..2fc2f217900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ - Add `Session.State.Unhandled` for unhandled errors that do not terminate the process ([#5919](https://github.com/getsentry/sentry-java/pull/5919)) + +### Improvements + +- Move ANR profiling out of experimental ([#6042](https://github.com/getsentry/sentry-java/pull/6042)) + ### Fixes - Keep dropped tombstone and ANR events dropped, instead of reporting the same app exit again at every app start ([#6002](https://github.com/getsentry/sentry-java/pull/6002))