Skip to content

test(profiling): pin Android RNSentryStart wiring of _experiments.profilingOptions#6060

Open
antonis wants to merge 2 commits intomainfrom
antonis/android-profiling-tests
Open

test(profiling): pin Android RNSentryStart wiring of _experiments.profilingOptions#6060
antonis wants to merge 2 commits intomainfrom
antonis/android-profiling-tests

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 28, 2026

📢 Type of change

  • Refactoring

📜 Description

Adds a new JUnit test class RNSentryProfilingOptionsTest under packages/core/RNSentryAndroidTester/app/src/test/java/io/sentry/react/ that pins the wiring of _experiments.profilingOptions from the JS bridge into SentryAndroidOptions via RNSentryStart.configureAndroidProfiling.

The 11 tests cover:

  • All three fields propagate when set together (profileSessionSampleRate, lifecycle: "trace", startOnAppStart: trueoptions.profileSessionSampleRate == 1.0, profileLifecycle == TRACE, isStartProfilerOnAppStart == true).
  • lifecycle: "manual"ProfileLifecycle.MANUAL.
  • lifecycle: "TRACE" → case-insensitive match.
  • startOnAppStart: false is honored.
  • Defaults are preserved when _experiments is missing, when _experiments has no profilingOptions, and when profilingOptions is empty.
  • Type mismatches (string for profileSessionSampleRate, number for lifecycle, string for startOnAppStart) log a SentryLevel.WARNING and leave the field unchanged.
  • Unknown lifecycle strings are silently ignored without a warning, matching the implementation's actual behavior (only type mismatches log).

This piggybacks on the existing RNSentryAndroidTester Gradle module and follows the conventions of the neighboring RNSentryStartTest.kt (JUnit4 + Mockito + JavaOnlyMap.of(...) fixtures + real SentryAndroidOptions() instances).

Note on scope: the issue mentioned considering pinning _experiments.enableUnhandledCPPExceptionsV2 on Android too. That option is @platform ios only (see packages/core/src/js/options.ts:361) and is not handled on Android by design — there's nothing to pin. Skipped.

💡 Motivation and Context

Closes #6016. The iOS bug fixed in #6012 (_experiments.profilingOptions silently ignored since v8.0.0) shipped because no test exercised the live init path's profiling wiring. The Android wiring is correct today, but it has no JUnit coverage either — so a future refactor moving configureAndroidProfiling out of getSentryAndroidOptions (or introducing a parallel init path the way the iOS one slipped in) would silently regress the same way. These tests close that gap with the same shape of coverage that pins the iOS path.

💚 How did you test it?

  • ./gradlew :app:testDebugUnitTest --tests "io.sentry.react.RNSentryProfilingOptionsTest" — 11/11 pass.
  • ./gradlew :app:testDebugUnitTest — full Android test suite still green.
  • yarn lint:android, yarn lint:kotlin, yarn build, yarn test, yarn circularDepCheck — all clean.
  • Mentally traced regression coverage: deleting any of the three options.set… calls inside configureAndroidProfiling causes the "all three fields propagate" test to fail. Removing the configureAndroidProfiling(...) call site causes all 11 tests to fail.

📝 Checklist

  • I added tests to verify 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.
  • All tests passing
  • No breaking changes

🔮 Next steps

…filingOptions

Add JUnit coverage for `RNSentryStart.configureAndroidProfiling` to catch a
future refactor moving it out of the live `getSentryAndroidOptions` call site
— the same regression shape as the iOS bug fixed in #6012, which slipped through
because the Android side had zero coverage for this wiring.

Closes #6016.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Apr 28, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 28, 2026

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 482.04 ms 536.54 ms 54.50 ms
Size 43.75 MiB 48.15 MiB 4.40 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 442.02 ms 456.52 ms 14.50 ms
2c735cc+dirty 414.09 ms 438.47 ms 24.38 ms
df5d108+dirty 527.06 ms 603.58 ms 76.52 ms
3ce5254+dirty 410.57 ms 448.48 ms 37.91 ms
3d377b5+dirty 406.18 ms 453.52 ms 47.34 ms
0d9949d+dirty 403.57 ms 437.00 ms 33.43 ms
4b87b12+dirty 421.82 ms 413.60 ms -8.22 ms
7ac3378+dirty 404.78 ms 439.84 ms 35.06 ms
890d145+dirty 504.54 ms 491.55 ms -12.99 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 43.75 MiB 48.08 MiB 4.33 MiB
2c735cc+dirty 43.75 MiB 48.08 MiB 4.33 MiB
df5d108+dirty 43.75 MiB 48.08 MiB 4.33 MiB
3ce5254+dirty 43.75 MiB 48.12 MiB 4.37 MiB
3d377b5+dirty 43.75 MiB 48.14 MiB 4.39 MiB
0d9949d+dirty 43.75 MiB 48.13 MiB 4.37 MiB
4b87b12+dirty 43.75 MiB 48.14 MiB 4.39 MiB
7ac3378+dirty 43.75 MiB 48.13 MiB 4.37 MiB
890d145+dirty 43.75 MiB 48.14 MiB 4.39 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@antonis antonis marked this pull request as ready for review April 28, 2026 13:19
@github-actions
Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 361.98 ms 409.38 ms 47.40 ms
Size 43.94 MiB 49.01 MiB 5.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms
2c735cc+dirty 435.20 ms 459.48 ms 24.28 ms
df5d108+dirty 434.82 ms 447.39 ms 12.57 ms
3ce5254+dirty 373.90 ms 427.84 ms 53.94 ms
3d377b5+dirty 425.38 ms 440.67 ms 15.30 ms
0d9949d+dirty 414.88 ms 428.68 ms 13.81 ms
4b87b12+dirty 356.23 ms 399.86 ms 43.63 ms
7ac3378+dirty 410.67 ms 442.60 ms 31.92 ms
890d145+dirty 486.42 ms 514.85 ms 28.43 ms
3817909+dirty 357.52 ms 391.52 ms 34.00 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB
2c735cc+dirty 43.94 MiB 48.94 MiB 5.00 MiB
df5d108+dirty 43.94 MiB 48.94 MiB 5.00 MiB
3ce5254+dirty 43.94 MiB 48.98 MiB 5.04 MiB
3d377b5+dirty 43.94 MiB 49.00 MiB 5.06 MiB
0d9949d+dirty 43.94 MiB 48.99 MiB 5.05 MiB
4b87b12+dirty 43.94 MiB 49.00 MiB 5.06 MiB
7ac3378+dirty 43.94 MiB 48.99 MiB 5.05 MiB
890d145+dirty 43.94 MiB 49.00 MiB 5.06 MiB
3817909+dirty 43.94 MiB 48.94 MiB 5.00 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.

Add Android JUnit coverage for configureAndroidProfiling

1 participant