Skip to content

ref(android): Inject the executor into init-time components - #6834

Draft
runningcode wants to merge 1 commit into
no/sentryruntime-foundationfrom
no/sentryruntime-init-executor
Draft

runningcode wants to merge 1 commit into
no/sentryruntime-foundationfrom
no/sentryruntime-init-executor

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

SentryAndroid.init now creates the executor right after the customer's callback and passes it to everything initializeIntegrationsAndProcessors builds. Before, each component read it off SentryOptions.

// SentryAndroid.init, right after the customer's callback
+ executor = LegacyOptionsBridge.executorOrNew(options);   // an executor set on the options still wins
+ runtimeBuilder.executorService(executor);
  initializeIntegrationsAndProcessors(options, executor, …);
    new AndroidConnectionStatusProvider(…, executor);
    new PersistingScopeObserver(options, executor);
    new AssetsModulesLoader(context, logger, executor);    // submits in its constructor
    new AndroidTransactionProfiler(…, executor);           // and the continuous profilers

// Sentry.init
- options.getExecutorService().submit(new MovePreviousSession(options));
+ runtime.getExecutorService().submit(new MovePreviousSession(options));
  // same for loadLazyFields, the options observers, the session finalizer and app-start profiling
  • NdkScopeObserver takes the executor in its constructor.
  • The old public constructors stay and read the executor off the options.
  • Code that can only get SentryOptions on 8.x reads the executor through LegacyOptionsBridge.executorOf(options). Each of these sites needs a decision in 9.0:
    • the Spring continuous profiler bean, which is created before Sentry.init;
    • AndroidLoggerBatchProcessor and AndroidMetricsBatchProcessor, created by the public create(options, client) factories;
    • SentryNdk.init and SentryNdkOutproc.init, which NdkIntegration calls by reflection;
    • InternalSentrySdk's session-file deletion.

💡 Motivation and Context

Part of JAVA-817. Stacked on #6830.

💚 How did you test it?

NdkScopeObserverTest now passes its executor in, and the profiler and options-initializer tests pass the executor explicitly.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the 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.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Retarget to main once #6830 merges. This conflicts with the disk-cache PR on the initializeIntegrationsAndProcessors signature; whichever merges second rebases.

Sentry.initConfigurations (old-profile cleanup, BackpressureMonitor, JVM continuous profiling) still reads the executor off the options, because it runs before the runtime is built until the executor-shutdown PR moves that earlier.

🤖 Generated with Claude Code

#skip-changelog

SentryAndroid.init now creates the executor right after the customer's
callback and passes it to everything initializeIntegrationsAndProcessors
builds, so those components no longer read it off SentryOptions. The
NdkScopeObserver and Sentry.init's own session and observer tasks use
it too.

Code that can only receive SentryOptions on 8.x, such as the public
batch processor factories and the reflective SentryNdk.init, reads the
executor through LegacyOptionsBridge.executorOf, which marks each site
for 9.0.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@linear-code

linear-code Bot commented Dec 1, 2026

Copy link
Copy Markdown

JAVA-817

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit fcf9137.

Main concerns: reach, public contract, host performance.

Rules that block low also fired:

  • R4: a public API record changed: sentry-android-ndk/api/sentry-android-ndk.api, sentry/api/sentry.api

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Dec 1, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.66.0 (1) release

⚙️ sentry-android Build Distribution Settings

This branch has not been deployed

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant