Skip to content

feat(logger): app-state-aware ANR parity — saveNonFatal + ossdk.crash.fatal#5

Merged
abdulraqeeb33 merged 5 commits into
mainfrom
feat/anr-app-state-and-fatal-flag
Jul 22, 2026
Merged

feat(logger): app-state-aware ANR parity — saveNonFatal + ossdk.crash.fatal#5
abdulraqeeb33 merged 5 commits into
mainfrom
feat/anr-app-state-and-fatal-flag

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Collaborator

Summary

Brings the shared logger module to parity with the Android SDK's SDK-4822 (app-state-aware ANR watchdog + fatal/non-fatal crash indicator), so the KMP logger path behaves like the otel path once adopted.

Stacked on #3 (fix/logger-review-followups) — this PR targets that branch, not main. Review/merge #3 first. The diff shown here is only the additive parity work.

Changes

  • ILogCrashReporter.saveNonFatal — records backgrounded main-thread blocks (and other retained warnings) at Severity.WARN, keeping them out of any severity-based crash/ANR metric while staying queryable. Synchronous + @Throws, matching fix(logger): address multi-model review findings from PR #1 #3's fatal-handler-safe crash API.
  • ossdk.crash.fatal indicatorsaveCrash tags true (FATAL), saveNonFatal tags false (WARN). Emitted as a typed OTLP bool_value, not the string "true", so it matches exactly what the OpenTelemetry SDK produced and the backend can segment on a stable flag rather than inferring intent from severity/exception type.
  • Narrow bool-attribute supportLogRecord/EncodableRecord gain a boolAttributes map; OtlpLogEncoder encodes them as AnyValue.bool_value (always writes false explicitly so it decodes to a definite value). String + bool attributes share the single 128-attribute LogLimits budget.

Why

The Android AndroidLogAnrDetector reuses the shared, JVM-tested AnrCheckEvaluator and needs a non-fatal sink for backgrounded blocks plus the explicit fatal flag; both are host-agnostic and belong in the shared module so iOS gets them for free.

Test plan

Made with Cursor

@abdulraqeeb33
abdulraqeeb33 changed the base branch from fix/logger-review-followups to main July 22, 2026 10:09
AR Abdul Azeez and others added 3 commits July 22, 2026 15:44
…dk.crash.fatal

Stacked on #3 (fix/logger-review-followups). Mirrors Android SDK-4822 in the shared
module so the logger path reaches parity with otel:
- ILogCrashReporter.saveNonFatal records backgrounded main-thread blocks at
  Severity.WARN (vs FATAL for saveCrash), keeping them out of crash/ANR metrics.
  Synchronous + @throws, matching #3's fatal-handler-safe crash API.
- Emit an explicit, typed ossdk.crash.fatal OTLP bool attribute (true for crashes/
  foreground ANRs, false for non-fatal) so the backend segments on a stable flag
  rather than inferring intent from severity/exception.type.
- Add narrow bool-attribute support to LogRecord/EncodableRecord/OtlpLogEncoder
  (AnyValue.bool_value) so the flag matches the type the OpenTelemetry SDK produced.

Co-authored-by: Cursor <cursoragent@cursor.com>
….save

emit/forceFlush/saveCrash do not need to be synchronous APIs. The crash
sink's forceFlush is a no-op (write already completed in emit). Hosts
bridge from fatal handlers with runBlocking; ILogFileStore.save stays
blocking so the bytes hit disk before process death.

Co-authored-by: Cursor <cursoragent@cursor.com>
…t work

Also prioritize bool attributes in the 128-attr budget so ossdk.crash.fatal
is not dropped when string attrs are near the cap.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33
abdulraqeeb33 force-pushed the feat/anr-app-state-and-fatal-flag branch from 1124137 to 5a5b60b Compare July 22, 2026 10:15
AR Abdul Azeez and others added 2 commits July 22, 2026 15:47
Co-authored-by: Cursor <cursoragent@cursor.com>
Public crash reporter stays sync so hosts can call from uncaught-exception
handlers without async bridging. Telemetry emit/forceFlush remain suspend;
LogCrashReporter bridges with runBlocking at that single boundary.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33
abdulraqeeb33 merged commit d7694bf into main Jul 22, 2026
1 check passed
@abdulraqeeb33
abdulraqeeb33 deleted the feat/anr-app-state-and-fatal-flag branch July 22, 2026 10:26
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