Decide session staleness on a monotonic clock in LifecycleWatcher

Ouverte
#6,663 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
56/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
android, java, kotlin
Domaine
backend, mobile

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
Kotlin
Étoiles
1.4k
Forks
483
Merge moyen
2 j 54 min
PR mergées (30 j)
207

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de getsentry/sentry-java

Toutes les issues de getsentry/sentry-java

Issues similaires

Plus d'issues Kotlin

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.