RUMM-319 Improve logging for app extensions #79
Closed
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.
What and why?
🚚 This PR addresses the enhancement discussed in #52 - sending logs immediately.
The origin of this enhancement idea was the use case of running the SDK in short-lived app extension. Default timing configuration for persistence and upload was not effective when running in such environment so the SDK did not always have enough time to upload logs to Datadog during app extension lifetime.
However, instead of implementing "send logs immediately" feature we decided to adjust timing configuration if SDK is running in app extension.
How?
An
Environment
abstraction is introduced:The
environment
is determined automatically during theDatadog.initialize()
call and provides custom timing configuration for each case. The.app
environment defaults to previous configuration and.appExtension
brings distinct values.The
.appExtension
environment:0.5s
after the SDK is initialized. This enables even very-short lived extensions to upload logs collected but not-yet-uploaded in the previous session.5s
for max upload delay. This means, every check will be performed in less than5s
(vs20s
in.app
environment).0.5
(vs0.9
in.app
). This significantly reduces the time for next upload if the extension performs intensive logging.A note on integration tests
💡 This PR adds only unit tests and necessary changes to benchmarks. It doesn't ship the integration test for app extension. Doing this will require changing the nature of our integration tests - from being a unit test target to UI Test target which launches the app and app extension. Not done in this PR, as I don't want to conflict with other open PRs.
Review checklist