Skip to content

chore(tracker): log WorkManager stop reasons and persistence errors#224

Draft
adsamcik wants to merge 1 commit into
dev/v10from
chore/job-quota-observability
Draft

chore(tracker): log WorkManager stop reasons and persistence errors#224
adsamcik wants to merge 1 commit into
dev/v10from
chore/job-quota-observability

Conversation

@adsamcik

Copy link
Copy Markdown
Owner

Summary

Observability follow-ups from the tracking-architecture review (P1/P3). Two small, additive, low-risk changes in :tracker:engine.

1. WorkManager stop-reason logging (Android 16 quota)

DailySummaryMaterializationWorker.doWork() now catches CancellationException and logs getStopReason() before re-throwing. Android 16 (API 36) made JobScheduler/WorkManager jobs count against the app's standby-bucket quota even while a foreground service is running, so this worker can now be throttled. Logging the stop reason makes quota-related stops diagnosable (STOP_REASON_QUOTA, STOP_REASON_CONSTRAINT_*, etc.). Cancellation still propagates so WorkManager reschedules as before — success/failure semantics are unchanged.

2. Route persistence errors to the crash reporter

PersistenceProcessor.flushTable() already logged DB flush failures to logcat (Log.w) and to a structured PersistenceErrorCollector flow — but that flow is exposed via the controller and consumed by no production code (only tests). It now also calls Reporter.report(e), so persistence failures reach the redacting crash reporter and become visible in diagnostics.

Verification

  • ./gradlew :tracker:engine:compileDebugKotlinBUILD SUCCESSFUL.
  • Reporter is safe to call before init (no-ops), so existing unit tests are unaffected.
  • WorkManager 2.11.1 supports getStopReason() (added 2.9.0).

Notes

Draft — opened for review. Broader getStopReason() logging in the other app workers (DatabaseMaintenanceWorker, GoalNotificationWorker, retention) is intentionally out of scope to keep this PR within one module.

- DailySummaryMaterializationWorker: log getStopReason() on cancellation so
  Android 16 job-quota throttling (jobs now count against quota even while an
  FGS runs) and other system stops are diagnosable; cancellation still
  propagates so WorkManager can reschedule.
- PersistenceProcessor: route DB flush failures to the redacting crash Reporter
  in addition to logcat. The structured errorCollector flow is exposed via the
  controller but currently observed only by optional UI, so failures were not
  reaching diagnostics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant