embrace-io / embrace-android-sdk

Embrace's Android SDK built on OpenTelemetry
https://embrace.io/docs/android/
Apache License 2.0
135 stars 11 forks source link

Save crashes synchronously and process other unbatched log requests in background thread #1322

Closed bidetofevil closed 1 month ago

bidetofevil commented 1 month ago

Goal

Changed the SendImmediately designation to a SendMode enum to additionally allow logs to be saved instead of sent, and use this to save crash logs rather than send them. This ensures they will be delivered on the next app startup in a consistent matter, rather than rely on our existing, flakey mechanism to attempt to send synchronously, and only if it fails, save the payload.

Bundled with this change is the need to serialize the log payload and create the request for other unbatched logs off the calling thread. Right now, they are not being done on a background thread - only sent through it - so this could be problematic depending on where it's being invoked. Instead, we will run them on the same scheduler that we use to run the log batching job.

Testing

Added unit tests everywhere to ensure this SendMode concept is passed down. Also added integration test to ensure that this works.

github-actions[bot] commented 1 month ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

bidetofevil commented 1 month ago

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @bidetofevil and the rest of your teammates on Graphite Graphite

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 93.75000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.99%. Comparing base (102cdd1) to head (628dfcb). Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ndroid/embracesdk/internal/arch/schema/SendMode.kt 71.42% 1 Missing and 1 partial :warning:
...ce/android/embracesdk/internal/logs/LogSinkImpl.kt 87.50% 0 Missing and 1 partial :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322/graphs/tree.svg?width=650&height=150&src=pr&token=4kNC8ceoVB&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io)](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io) ```diff @@ Coverage Diff @@ ## master #1322 +/- ## ========================================== + Coverage 82.97% 82.99% +0.01% ========================================== Files 482 483 +1 Lines 11139 11156 +17 Branches 1702 1707 +5 ========================================== + Hits 9243 9259 +16 Misses 1162 1162 - Partials 734 735 +1 ``` | [Files with missing lines](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io) | Coverage Δ | | |---|---|---| | [...android/embracesdk/internal/arch/schema/EmbType.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Farch%2Fschema%2FEmbType.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2FyY2gvc2NoZW1hL0VtYlR5cGUua3Q=) | `89.58% <100.00%> (ø)` | | | [...roid/embracesdk/internal/arch/schema/SchemaType.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Farch%2Fschema%2FSchemaType.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2FyY2gvc2NoZW1hL1NjaGVtYVR5cGUua3Q=) | `99.30% <100.00%> (ø)` | | | [...d/embracesdk/internal/arch/schema/TelemetryType.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Farch%2Fschema%2FTelemetryType.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2FyY2gvc2NoZW1hL1RlbGVtZXRyeVR5cGUua3Q=) | `100.00% <ø> (ø)` | | | [...sdk/internal/envelope/log/LogEnvelopeSourceImpl.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Fenvelope%2Flog%2FLogEnvelopeSourceImpl.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2VudmVsb3BlL2xvZy9Mb2dFbnZlbG9wZVNvdXJjZUltcGwua3Q=) | `100.00% <100.00%> (ø)` | | | [...esdk/internal/envelope/log/LogPayloadSourceImpl.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Fenvelope%2Flog%2FLogPayloadSourceImpl.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2VudmVsb3BlL2xvZy9Mb2dQYXlsb2FkU291cmNlSW1wbC5rdA==) | `100.00% <100.00%> (ø)` | | | [...id/embracesdk/internal/logs/LogOrchestratorImpl.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Flogs%2FLogOrchestratorImpl.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2xvZ3MvTG9nT3JjaGVzdHJhdG9ySW1wbC5rdA==) | `93.87% <100.00%> (+0.39%)` | :arrow_up: | | [...ace/android/embracesdk/internal/logs/LogRequest.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Flogs%2FLogRequest.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2xvZ3MvTG9nUmVxdWVzdC5rdA==) | `100.00% <100.00%> (ø)` | | | [...sdk/internal/opentelemetry/EmbraceAttributeKeys.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Fopentelemetry%2FEmbraceAttributeKeys.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL29wZW50ZWxlbWV0cnkvRW1icmFjZUF0dHJpYnV0ZUtleXMua3Q=) | `100.00% <100.00%> (ø)` | | | [...ce/android/embracesdk/internal/logs/LogSinkImpl.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Flogs%2FLogSinkImpl.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2xvZ3MvTG9nU2lua0ltcGwua3Q=) | `91.30% <87.50%> (-3.44%)` | :arrow_down: | | [...ndroid/embracesdk/internal/arch/schema/SendMode.kt](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322?src=pr&el=tree&filepath=embrace-android-core%2Fsrc%2Fmain%2Fkotlin%2Fio%2Fembrace%2Fandroid%2Fembracesdk%2Finternal%2Farch%2Fschema%2FSendMode.kt&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io#diff-ZW1icmFjZS1hbmRyb2lkLWNvcmUvc3JjL21haW4va290bGluL2lvL2VtYnJhY2UvYW5kcm9pZC9lbWJyYWNlc2RrL2ludGVybmFsL2FyY2gvc2NoZW1hL1NlbmRNb2RlLmt0) | `71.42% <71.42%> (ø)` | | ... and [3 files with indirect coverage changes](https://app.codecov.io/gh/embrace-io/embrace-android-sdk/pull/1322/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=embrace-io)
bidetofevil commented 1 month ago

Merge activity