Turn SentryOptions into a customer-facing interface

未關閉
#6,405 1 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@runningcode 已經在處理了。

開始於 2026年10月28日。

評估

這個 Issue 還沒有評估資料。

描述

Android Platform: Android

Problem

SentryOptions is a ~4,300-line concrete class with ~340 public methods that mixes two concerns:

  • Customer configuration: DSN, sample rates, beforeSend* callbacks, enable* flags, and sub-options (Logs, Metrics, Cron, Proxy, …).
  • SDK runtime state and internal collaborators: executor service, serializer, envelope reader, transport factory, envelope disk cache, transaction/continuous profilers, modules and debug-meta loaders, thread checker, composite performance collector, connection status provider, replay controller, date provider, monotonic ticker, and so on. ~53 members already carry @ApiStatus.Internal, which tells us they don't belong on the public type.

Consequences:

  • Customers see, and can set, SDK internals. Binary compatibility makes every internal getter/setter effectively public API, so it's hard to change them.
  • SentryAndroidOptions and the three Spring Boot SentryProperties classes extend the concrete class, so they inherit all of the internal state too. Spring Boot binds properties straight onto that object (see getsentry/sentry-java#6369).
  • The SDK mutates the same object the customer configured (defaults filled in, collaborators swapped in during init). It's hard to tell what is configuration and what is state, or when options are "done".

Idea

Make what customers configure an interface that contains only the customer-facing configuration. Move the SDK internals into a separate internal object that init builds from the configured options (holding the executor, serializer, transport, caches, profilers, etc.).

Sentry.init(options -> { ... }) keeps its shape for customers; only the type behind options changes.

Open questions

  • Interface, builder, or a concrete class with the internals removed? Which gives the easiest migration and works with Java 8?
  • How do Android and Spring Boot options compose: interface inheritance or composition?
  • Can options become read-only after init? What about settings that are meant to change at runtime (e.g., getsentry/sentry-java#5486)?
  • Which internals do customers legitimately set today (e.g., setTransportFactory in tests, setLogger, setSerializer), and which need a supported public hook?
  • Migration path: what can we deprecate in 8.x first, and how are the hybrid SDKs (React Native, Flutter, Unity, KMP) that call into SentryOptions/SentryAndroidOptions affected?
主要語言
Kotlin
星號
1.4k
分支
483
平均合併
2 天 54 分鐘
30 天內合併 PR
207

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-java 的其他 Issue

查看 getsentry/sentry-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。