Skip to content

ref(android): Hand SentryRuntime to the SDK's integrations - #6832

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

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

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

The SDK's integrations implement InternalIntegration, so Sentry.init passes them the SentryRuntime and they take their executor and envelope cache from it instead of from SentryOptions.

final class AnrV2Integration implements InternalIntegration {

  // The old entry point keeps working: it builds a runtime over what's on the options.
  public void register(IScopes scopes, SentryOptions options) {
    register(scopes, options, LegacyOptionsBridge.runtimeOf(options));   // creates nothing
  }

  public void register(IScopes scopes, SentryOptions options, SentryRuntime runtime) {
    this.executorService = runtime.getExecutorService();
    new ApplicationExitInfoHistoryDispatcher(…, runtime.getEnvelopeDiskCache());
  }
}

// The tests declare exactly what the integration uses.
val runtime = SentryRuntime.builder()
  .executorService(ImmediateExecutorService())
  .envelopeDiskCache(cache)
  .buildForTest()                        // reading anything else throws
sut.register(scopes, options, runtime)
  • ANR v2, Tombstone and MemoryLimiter use both the executor and the cache, and they move here in full rather than being split across the cache and executor PRs.
  • The other integrations (ActivityLifecycle, Anr, AppComponentsBreadcrumbs, EnvelopeFileObserver, FeedbackShake, SendCachedEnvelope, SystemEventsBreadcrumbs, AnrProfiling, and SendCachedEnvelopeFireAndForget in sentry) store the runtime's executor in a volatile field.
  • register stays final where it was.

💡 Motivation and Context

Part of JAVA-817. Stacked on #6830.

💚 How did you test it?

The ANR, Tombstone and MemoryLimiter tests now use strict test runtimes. Other integration tests are unchanged and still go through the two-argument register.

📝 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.

🤖 Generated with Claude Code

#skip-changelog

The SDK's integrations become InternalIntegrations, so Sentry.init
passes them the runtime and they take their executor and envelope cache
from it instead of from SentryOptions. Their two-argument register keeps
working by building a runtime over the collaborators on the options.

The ANR, Tombstone and MemoryLimiter tests now build a strict runtime
holding only what each integration uses.

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 added the risk: high PR risk score: high label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

PR risk: high

For commit 9c190de.

Main concerns: public contract, reach, host performance.

Rules that block low also fired:

  • R4: a public API record changed: sentry-android-core/api/sentry-android-core.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: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant