Decide session staleness on a monotonic clock in LifecycleWatcher

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

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
56/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
android, java, kotlin
領域
backend, mobile

研究方向

Start with LifecycleWatcher.isSessionOnScopeStale() in sentry-android-core/src/main/java/io/sentry/android/core/LifecycleWatcher.java, then inspect Session and the existing background-path Deadline usage. Check how session start time is stored and serialized; the change is done when the in-memory monotonic start tick supports the staleness decision and is not serialized. The issue points to no specific test, so locate relevant lifecycle and session tests before making the change.

由索引模型根據 Issue 內容生成。

描述

Platform: Android Platform: Java

When the app comes to the foreground with no background window pending, LifecycleWatcher.isSessionOnScopeStale() decides whether to start a new session. This happens when SDK init started the session, rather than the user leaving and coming back. The check compares Session.getStarted() with the wall clock.

A clock step between SDK init and the first foreground gets this wrong:

  • A forward step can start a second session when it shouldn't.
  • A backward step can keep a stale session.

Release health counts session starts, so either case can move session counts.

Fix

Let a Session remember the monotonic tick it started on. Keep it in memory only and don't serialize it. Then decide staleness with a Deadline, as the background path already does.

Context

getsentry/sentry-java#5580 and getsentry/sentry-java#6585 were closed on 2026-11-18 because Relay ignores the session seq and duration fields. This is the one session clock issue left that affects counts.

Agent notes
  • sentry-android-core/src/main/java/io/sentry/android/core/LifecycleWatcher.java: see isSessionOnScopeStale() and its TODO [MAJOR] on 9.x.x (checked 2026-11-18).
  • Relay at f218978dbb: relay-server/src/metrics_extraction/sessions/mod.rs buckets session metrics by started and emits only counts.
主要語言
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 摘要。