feat(logger): app-state-aware ANR parity — saveNonFatal + ossdk.crash.fatal#5
Merged
Merged
Conversation
…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
force-pushed
the
feat/anr-app-state-and-fatal-flag
branch
from
July 22, 2026 10:15
1124137 to
5a5b60b
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
otelpath once adopted.Changes
ILogCrashReporter.saveNonFatal— records backgrounded main-thread blocks (and other retained warnings) atSeverity.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.fatalindicator —saveCrashtagstrue(FATAL),saveNonFataltagsfalse(WARN). Emitted as a typed OTLPbool_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.LogRecord/EncodableRecordgain aboolAttributesmap;OtlpLogEncoderencodes them asAnyValue.bool_value(always writesfalseexplicitly so it decodes to a definite value). String + bool attributes share the single 128-attributeLogLimitsbudget.Why
The Android
AndroidLogAnrDetectorreuses the shared, JVM-testedAnrCheckEvaluatorand 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
./gradlew :logger:testDebugUnitTest :logger:iosSimulatorArm64Test spotlessCheck(green)bool_value(true→1, false written explicitly);saveCrash→FATAL+ossdk.crash.fatal=1,saveNonFatal→WARN+ossdk.crash.fatal=0:OneSignal:corecompiles and crash-package tests pass with this commit pinned as the submodule (feat(logger): [SDK-4835] adopt shared KMP logger module via OneSignal-KMP-SDK submodule OneSignal-Android-SDK#2687)Made with Cursor