Decide session staleness on a monotonic clock in LifecycleWatcher

Aberta
#6,663 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
56/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
android, java, kotlin
Domínio
backend, mobile

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
Kotlin
Estrelas
1.4k
Forks
483
Merge médio
2d 54min
PRs com merge (30d)
207

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de getsentry/sentry-java

Todas as issues de getsentry/sentry-java

Issues semelhantes

Mais issues de Kotlin

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.