This repository was archived by the owner on Aug 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 220
sdk offline caching considerations #509
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,9 +155,35 @@ Include a list of loaded libraries (and versions) when sending an event. | |
|
|
||
| ## Buffer to Disk | ||
|
|
||
| Write events to disk before attempting to send, so that they can be retried in the event of a temporary network failure. Needs to implement a cap on the number of stored events. | ||
| This feature is also known as 'Offline Caching'. | ||
|
|
||
| This is mostly useful on mobile clients where connectivity is often not available. | ||
| Write events to disk before attempting to send, so that they can be retried in the event of a temporary network failure. Needs to implement a cap on the number of stored events. This is mostly useful on mobile and desktop(e.g: laptop) apps, where stable connectivity is often not available. | ||
|
|
||
| #### Dealing with failures | ||
|
|
||
| It's important to note that retry is only considered in the event of a network failure. For example: | ||
|
|
||
| * Connection timeout | ||
| * DSN resolution failure | ||
| * Connection reset by peer | ||
|
|
||
| Other failures, like those caused by processing the file in the SDK itself, the payload should be discarded since those are likely to end up on an endless retry. | ||
| If the event reached Sentry and a HTTP response status code was received, even in the event of a `500` response, the event should be discarded. | ||
|
|
||
| #### Additional capabilities | ||
|
|
||
| Consider having the SDK retry sending events once the device is back online, when such notification exists in the platform. | ||
|
|
||
| Once the device is back online, the SDK is likely going to empty its disk queue in a quick burst of requests. This can trigger different abuse filters in Sentry. To account for that, it's considered to add a small delay between cached event captures. A recommended value is 100 milliseconds. | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| If the SDK is being [rate-limited](/sdk/rate-limiting/), which causes the SDK to drop any event that reaches its HTTP transport, cosider stop consuming the disk cache until the `Retry-After` timeout is reached or the app restarts. | ||
bruno-garcia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #### Example implementations | ||
|
|
||
| - [C#](https://github.com/getsentry/sentry-dotnet/blob/main/src/Sentry/Internal/Http/CachingTransport.cs) | ||
| - [Java](https://github.com/getsentry/sentry-java/blob/main/sentry/src/main/java/io/sentry/cache/EnvelopeCache.java) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likely not the best class to be documented here, maybe
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just a pointer to folks, didn't want to list all classes needed but something folks can find references from |
||
| - [Objective-C](https://github.com/getsentry/sentry-cocoa/blob/master/Sources/Sentry/SentryHttpTransport.m) | ||
| - [TypeScript](https://github.com/getsentry/sentry-electron/blob/master/src/main/transports/electron-offline-net.ts) | ||
|
|
||
| ## HTTP Proxy | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.