-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save crashes synchronously and process other unbatched log requests i…
…n background thread (#1322) ## 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.
- Loading branch information
1 parent
f80b515
commit 9771d7f
Showing
25 changed files
with
273 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
6 changes: 0 additions & 6 deletions
6
...ore/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/SendImmediately.kt
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...droid-core/src/main/kotlin/io/embrace/android/embracesdk/internal/arch/schema/SendMode.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.embrace.android.embracesdk.internal.arch.schema | ||
|
||
import io.embrace.android.embracesdk.internal.arch.schema.SendMode.DEFAULT | ||
import io.embrace.android.embracesdk.internal.arch.schema.SendMode.DEFER | ||
import io.embrace.android.embracesdk.internal.arch.schema.SendMode.IMMEDIATE | ||
|
||
/** | ||
* How a given payload should be delivered to the Embrace server | ||
*/ | ||
public enum class SendMode { | ||
/** | ||
* Use the default delivery semantics - no customization required | ||
*/ | ||
DEFAULT, | ||
|
||
/** | ||
* If supported for that signal/payload type, deliver this as soon as possible and do not batch | ||
*/ | ||
IMMEDIATE, | ||
|
||
/** | ||
* Queue for delivery at the next convenient time. Used when the delivery environment is unstable, e.g. when an app is about to crash. | ||
*/ | ||
DEFER | ||
} | ||
|
||
public fun String.toSendMode(): SendMode { | ||
return when (lowercase()) { | ||
"immediate" -> IMMEDIATE | ||
"defer" -> DEFER | ||
else -> DEFAULT | ||
} | ||
} |
This file contains 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
3 changes: 2 additions & 1 deletion
3
.../src/main/kotlin/io/embrace/android/embracesdk/internal/envelope/log/LogEnvelopeSource.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package io.embrace.android.embracesdk.internal.envelope.log | ||
|
||
import io.embrace.android.embracesdk.internal.logs.LogRequest | ||
import io.embrace.android.embracesdk.internal.payload.Envelope | ||
import io.embrace.android.embracesdk.internal.payload.LogPayload | ||
|
||
public interface LogEnvelopeSource { | ||
public fun getBatchedLogEnvelope(): Envelope<LogPayload> | ||
|
||
public fun getNonbatchedEnvelope(): List<Envelope<LogPayload>> | ||
public fun getSingleLogEnvelopes(): List<LogRequest<Envelope<LogPayload>>> | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
6 changes: 6 additions & 0 deletions
6
...ce-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/logs/LogRequest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.embrace.android.embracesdk.internal.logs | ||
|
||
/** | ||
* A wrapper for a log payload that stipulates whether its delivery should be deferred or sent immediately | ||
*/ | ||
public data class LogRequest<T>(val payload: T, val defer: Boolean = false) |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.