Skip to content

ref(core): Add InternalServices for what the SDK owns - #6830

Open
runningcode wants to merge 4 commits into
mainfrom
no/sentryruntime-foundation
Open

runningcode wants to merge 4 commits into
mainfrom
no/sentryruntime-foundation

Conversation

@runningcode

@runningcode runningcode commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Adds io.sentry.internal.InternalServices, an immutable holder for the SDK's internal services: the objects the SDK creates and manages for itself rather than the customer, namely the serializer, the executor and the envelope disk cache. It is built once per Sentry.init. Nothing reads from it yet; follow-up PRs move each internal service's readers to constructor injection.

  • LegacyOptionsBridge builds InternalServices from what is on SentryOptions and copies it back, so code that still reads the options sees the same instances.
  • InternalIntegration lets Sentry.init hand InternalServices to SDK integrations.
  • Sentry.init and SentryAndroid.init take an InternalServices.Builder through new internal overloads. Hybrid SDKs get InternalSentrySdk.init(context, logger, (options, services) -> …) and InternalSentrySdk.getInternalServices(). A disk cache a hybrid SDK sets on the builder takes effect with ref(core): Inject the envelope disk cache from InternalServices #6833. Until then, the platform's cache on the options wins. Hybrid SDKs keep setting the executor on the options until 9.0, because on Android it's already in use before their callback runs.
// Sentry.init
  initConfigurations(options);                 // still creates the EnvelopeCache on the options
  bindClient(new SentryClient(options));
- if (options.getExecutorService().isClosed())
-   options.setExecutorService(new SentryExecutorService(options));
+ services = LegacyOptionsBridge.buildServices(servicesBuilder, options);
+ InternalServices.setCurrent(services);           // for hybrid SDKs only
  for (integration : options.getIntegrations())
+   if (integration instanceof InternalIntegration) integration.register(scopes, options, services);
+   else
      integration.register(scopes, options);

// LegacyOptionsBridge.buildServices(builder, options)
  builder.lazySerializer(() -> options.getSerializer());        // the same instance, created lazily
  if (!builder.hasExecutorService()) builder.executorService(executorOrNew(options));
  if (options.cache is not NoOp) builder.envelopeDiskCache(options.cache);  // a customer setter wins
  services = builder.build(options);                             // defaults for anything unset
  options.setExecutorService(services.executor);                 // the getters on the options
  options.setEnvelopeDiskCache(services.cache);                  // see the same objects

No behavior change: InternalServices is built where init used to replace a closed executor, and it reuses the disk cache initConfigurations already created.

💡 Motivation and Context

Part of JAVA-817. Customers should only configure SentryOptions. Moving the SDK's internals off it lets 9.0 remove them from the public API.

💚 How did you test it?

InternalServicesTest, plus the existing sentry and sentry-android-core unit tests.

📝 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

Separate PRs move executor shutdown, the integrations, the disk cache and the init-time executor users onto InternalServices. A last PR deprecates the SentryOptions accessors.

🤖 Generated with Claude Code

#skip-changelog

@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 221fe03.

Main concerns: reach, public contract, 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.67.0 (1) release

⚙️ sentry-android Build Distribution Settings

SentryRuntime holds the collaborators the SDK owns rather than the
customer (serializer, executor, envelope disk cache). Sentry.init builds
it once, through LegacyOptionsBridge, from what is on SentryOptions and
copies it back, so existing readers see the same instances. Nothing
reads from it yet; follow-up PRs move the readers to constructor
injection before the SentryOptions accessors get deprecated.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/sentryruntime-foundation branch from 4b9b580 to a993645 Compare December 3, 2026 12:24
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
"Collaborators" read as jargon. "Internal services" says what they are:
the objects the SDK creates and manages for itself, as opposed to what
the customer configures on SentryOptions.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
@runningcode runningcode changed the title ref(core): Add SentryRuntime for the SDK's own collaborators ref(core): Add SentryRuntime for the SDK's internal services Dec 3, 2026
io.sentry.protocol.SentryRuntime already exists as the event's runtime
context, so the API listed two public SentryRuntime classes.
InternalServices says what the class holds, in the words its docs
already use.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Dec 3, 2026
@runningcode runningcode changed the title ref(core): Add SentryRuntime for the SDK's internal services ref(core): Add InternalServices for what the SDK owns Dec 3, 2026
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 3, 2026
On Android the executor already exists, and integrations start using
it, before the hybrid SDK's callback runs. An executor set on the
InternalServices builder from that callback would replace it without
closing it. Until 9.0, hybrid SDKs set their executor on SentryOptions,
which the bridge already honors.

Part of JAVA-817

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026
@runningcode
runningcode marked this pull request as ready for review December 3, 2026 16:23
@runningcode
runningcode requested review from a team and adinauer as code owners December 3, 2026 16:23
@runningcode
runningcode requested review from 0xadam-brown and markushi and removed request for a team December 3, 2026 16:24
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 3, 2026

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