Skip to content

feat(android): Add anrProfilingSampleRate option - #6673

Open
antonis wants to merge 2 commits into
mainfrom
feat/android-anr-profiling-sample-rate
Open

feat(android): Add anrProfilingSampleRate option#6673
antonis wants to merge 2 commits into
mainfrom
feat/android-anr-profiling-sample-rate

Conversation

@antonis

@antonis antonis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • New feature
  • Enhancement

📜 Description

Adds a new anrProfilingSampleRate SDK option that exposes Android ANR profiling to React Native users.

When set to a value greater than 0.0, the native Android SDK profiles the main thread while an ANR (Application Not Responding) is happening and attaches the resulting profile to the ANR event. The value is the probability (0.01.0) that any given ANR is profiled.

Wiring:

  • New anrProfilingSampleRate?: number option on BaseReactNativeOptions (options.ts), Android-only, JSDoc'd.
  • Consumed in RNSentryStart.getSentryAndroidOptions(...) with a ReadableType.Number guard, applied via SentryAndroidOptions.setAnrProfilingSampleRate(...).
  • Flows to native through the existing initNativeSdk options passthrough — no bridge/codegen spec change needed.

It is independent of UI/transaction profiling (profilesSampleRate, _experiments.profilingOptions).

💡 Motivation and Context

ANR profiling graduated out of experimental in sentry-java 8.55.0 (getsentry/sentry-java#6042), which RN now bundles. RN previously had no way to configure it from JS-only init — this closes that gap.

Closes #6661. Follow-up from the 8.55.0 bump (#6658).

💚 How did you test it?

  • Added Kotlin tests in RNSentryStartTest.kt: sample rate applied & profiling enabled, default (null/disabled), non-number ignored.
  • Added a JS test in wrapper.test.ts verifying the value is forwarded to the native SDK.
  • Verified setAnrProfilingSampleRate(Double) / isAnrProfilingEnabled() against the bundled sentry-android 8.55.0 API.
  • yarn build:sdk, JS lint (oxlint), and google-java-format pass on the changed source.

📝 Checklist

🔮 Next steps

antonis and others added 2 commits September 4, 2026 10:10
Expose Android ANR profiling (stable since sentry-java 8.55.0) through a new
`anrProfilingSampleRate` JS option. When set > 0.0, the SDK profiles the main
thread while an ANR is happening and attaches the profile to the ANR event.

The value flows through initNativeSdk's options passthrough and is applied via
SentryAndroidOptions.setAnrProfilingSampleRate on the native side.

Closes #6661

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(android): Add anrProfilingSampleRate option by antonis in #6673
  • chore(deps): update Cocoa SDK to v9.27.0 by github-actions in #6670
  • chore(deps): update Sentry Android Gradle Plugin to v6.21.0 by github-actions in #6671
  • chore(deps): Bump fast-uri to ^3.1.6 to resolve security alerts by antonis in #6662
  • chore(deps): Bump qs to ^6.16.0 to resolve security alerts by antonis in #6663
  • chore(deps): Bump @xmldom/xmldom pins to patched versions to resolve security alerts by antonis in #6664
  • docs: Revamp root and nested AGENTS.md by antonis in #6666

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 803f47f

@sentry

sentry Bot commented Sep 4, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.25.0 (105) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3856.02 ms 1236.92 ms -2619.10 ms
Size 5.15 MiB 6.88 MiB 1.73 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ecf47a2+dirty 3835.20 ms 1222.43 ms -2612.77 ms
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms
5ee78d6+dirty 3847.52 ms 1224.27 ms -2623.25 ms
890d145+dirty 1223.59 ms 1231.37 ms 7.78 ms
e763471+dirty 3841.16 ms 1218.06 ms -2623.09 ms
3d31fcf+dirty 3838.09 ms 1223.46 ms -2614.63 ms
9210ae6+dirty 3815.93 ms 1214.14 ms -2601.79 ms
26843eb+dirty 3861.60 ms 1238.77 ms -2622.82 ms
7a89652+dirty 3861.46 ms 1229.61 ms -2631.85 ms
9ad4522+dirty 3850.40 ms 1222.40 ms -2628.00 ms

App size

Revision Plain With Sentry Diff
ecf47a2+dirty 4.98 MiB 6.46 MiB 1.49 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5ee78d6+dirty 5.15 MiB 6.69 MiB 1.53 MiB
890d145+dirty 3.38 MiB 4.77 MiB 1.38 MiB
e763471+dirty 4.98 MiB 6.51 MiB 1.53 MiB
3d31fcf+dirty 4.98 MiB 6.56 MiB 1.58 MiB
9210ae6+dirty 5.15 MiB 6.68 MiB 1.53 MiB
26843eb+dirty 4.98 MiB 6.53 MiB 1.55 MiB
7a89652+dirty 5.15 MiB 6.70 MiB 1.55 MiB
9ad4522+dirty 4.98 MiB 6.56 MiB 1.58 MiB

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 433.55 ms 456.57 ms 23.01 ms
Size 50.56 MiB 56.46 MiB 5.90 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
f9c1ed4+dirty 431.00 ms 466.22 ms 35.22 ms
c2e182c+dirty 471.64 ms 553.59 ms 81.95 ms
41d6254+dirty 424.45 ms 474.34 ms 49.89 ms
af33f3b+dirty 434.90 ms 506.14 ms 71.24 ms
882f8ae+dirty 399.98 ms 427.06 ms 27.08 ms
0b5120f+dirty 503.22 ms 538.60 ms 35.38 ms
774257e+dirty 407.09 ms 447.46 ms 40.37 ms
bf168a4+dirty 418.21 ms 489.74 ms 71.53 ms
5569641+dirty 406.43 ms 428.51 ms 22.08 ms
c151573+dirty 530.34 ms 559.43 ms 29.09 ms

App size

Revision Plain With Sentry Diff
f9c1ed4+dirty 49.74 MiB 54.86 MiB 5.12 MiB
c2e182c+dirty 49.74 MiB 54.85 MiB 5.11 MiB
41d6254+dirty 48.30 MiB 53.60 MiB 5.30 MiB
af33f3b+dirty 49.74 MiB 55.09 MiB 5.35 MiB
882f8ae+dirty 48.30 MiB 53.60 MiB 5.29 MiB
0b5120f+dirty 48.30 MiB 53.58 MiB 5.28 MiB
774257e+dirty 48.30 MiB 53.58 MiB 5.28 MiB
bf168a4+dirty 49.74 MiB 55.09 MiB 5.35 MiB
5569641+dirty 48.30 MiB 53.48 MiB 5.18 MiB
c151573+dirty 48.30 MiB 53.54 MiB 5.24 MiB

@antonis
antonis marked this pull request as ready for review September 4, 2026 08:41
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3837.22 ms 1207.87 ms -2629.35 ms
Size 5.15 MiB 6.88 MiB 1.73 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
71abba0+dirty 3852.70 ms 1224.53 ms -2628.16 ms
bc0d8cf+dirty 3834.64 ms 1223.91 ms -2610.73 ms
68ae91b+dirty 3836.36 ms 1222.04 ms -2614.32 ms
267d3ed+dirty 3860.14 ms 1223.39 ms -2636.76 ms
f170ec3+dirty 3844.74 ms 1222.67 ms -2622.07 ms
b9bebee+dirty 3858.02 ms 1231.92 ms -2626.11 ms
d038a14+dirty 3831.11 ms 1216.30 ms -2614.81 ms
853723c+dirty 3849.33 ms 1221.07 ms -2628.26 ms
e763471+dirty 3826.10 ms 1221.52 ms -2604.58 ms
3d31fcf+dirty 3857.46 ms 1237.17 ms -2620.29 ms

App size

Revision Plain With Sentry Diff
71abba0+dirty 5.15 MiB 6.67 MiB 1.52 MiB
bc0d8cf+dirty 5.15 MiB 6.67 MiB 1.51 MiB
68ae91b+dirty 4.98 MiB 6.46 MiB 1.48 MiB
267d3ed+dirty 5.15 MiB 6.69 MiB 1.54 MiB
f170ec3+dirty 5.15 MiB 6.69 MiB 1.53 MiB
b9bebee+dirty 5.15 MiB 6.68 MiB 1.53 MiB
d038a14+dirty 5.15 MiB 6.67 MiB 1.51 MiB
853723c+dirty 5.15 MiB 6.69 MiB 1.53 MiB
e763471+dirty 4.98 MiB 6.51 MiB 1.53 MiB
3d31fcf+dirty 4.98 MiB 6.56 MiB 1.58 MiB

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 472.25 ms 519.10 ms 46.85 ms
Size 50.56 MiB 56.46 MiB 5.90 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
eb93136+dirty 500.37 ms 532.58 ms 32.21 ms
9210ae6+dirty 444.14 ms 459.80 ms 15.66 ms
94af3bd+dirty 413.04 ms 451.76 ms 38.71 ms
7d6fd3a+dirty 435.06 ms 458.78 ms 23.72 ms
15d4514+dirty 413.63 ms 449.62 ms 35.99 ms
9ad4522+dirty 432.43 ms 450.91 ms 18.49 ms
0a147b2+dirty 442.80 ms 522.24 ms 79.44 ms
7887847+dirty 420.47 ms 460.55 ms 40.08 ms
a3265b6+dirty 410.96 ms 444.76 ms 33.80 ms
57e0069+dirty 442.25 ms 486.64 ms 44.39 ms

App size

Revision Plain With Sentry Diff
eb93136+dirty 48.30 MiB 53.58 MiB 5.28 MiB
9210ae6+dirty 48.30 MiB 53.54 MiB 5.23 MiB
94af3bd+dirty 48.30 MiB 53.57 MiB 5.26 MiB
7d6fd3a+dirty 43.94 MiB 49.00 MiB 5.06 MiB
15d4514+dirty 48.30 MiB 53.60 MiB 5.30 MiB
9ad4522+dirty 49.74 MiB 55.38 MiB 5.63 MiB
0a147b2+dirty 49.74 MiB 55.08 MiB 5.34 MiB
7887847+dirty 49.74 MiB 54.81 MiB 5.07 MiB
a3265b6+dirty 48.30 MiB 53.58 MiB 5.28 MiB
57e0069+dirty 49.74 MiB 54.85 MiB 5.11 MiB

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

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANR profiling is out of experimental in Android SDK 8.55.0 — review RN docs/config

1 participant