fix(android): [Data Collection 15] Scope device info cache to SDK options#5831
Draft
adinauer wants to merge 1 commit into
Draft
fix(android): [Data Collection 15] Scope device info cache to SDK options#5831adinauer wants to merge 1 commit into
adinauer wants to merge 1 commit into
Conversation
Store DeviceInfoUtil on each SentryAndroidOptions instance so repeated SDK initializations cannot reuse stale collection policy or Android services. Preserve lazy initialization while allowing old and new clients to retain their own device context. Refs #5666 Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Jul 24, 2026
📲 Install BuildsAndroid
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Data Collection)
📜 Description
Scope
DeviceInfoUtilto eachSentryAndroidOptionsinstance instead of keeping one process-global singleton.The existing
DeviceInfoUtil.getInstance(context, options)entry point remains, but now delegates to a lazily initialized utility owned by the supplied options. Repeated calls with the same options reuse cached device information, while different SDK initializations keep their collection policy, logger, connection provider, root-check setting, and additional-context settings isolated.Remove the test-only global reset because fresh options now provide test isolation naturally.
💡 Motivation and Context
The user information policy introduced in the preceding stack PR exposed a pre-existing lifecycle problem: Android auto-init followed by manual init could continue reading the first initialization's options from the process-global
DeviceInfoUtil. That could attachdevice.iddespite the active initialization settingdataCollection.userInfo=false, and could also retain stale additional-context and root-check behavior.Owning the cache from
SentryAndroidOptionsgives every SDK initialization one internally consistent utility without a static map or process-lifetime references to old options.Refs #5666
💚 How did you test it?
./gradlew spotlessApply apiDump./gradlew :sentry-android-core:testDebugUnitTest --tests='io.sentry.android.core.DeviceInfoUtilTest' --tests='io.sentry.android.core.DefaultAndroidEventProcessorTest' --tests='io.sentry.android.core.ApplicationExitInfoEventProcessorTest' --tests='io.sentry.android.core.InternalSentrySdkTest' :sentry-android-core:apiCheck :sentry-android-core:spotlessJavaCheck :sentry-android-core:spotlessKotlinCheckgit diff --check📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Continue the remaining Data Collection configuration and documentation work.
#skip-changelog