sentry-java / rules
Cursor rule1.4k starsChanged 7 months agoMITView on GitHub
Java SDK Offline behaviour
Trending
Quiet this year.about the whole repository
Who's talking about getsentry/sentry-java
- getsentry/sentry“[Mobile Replay] Capture Network request/response bodies”GitHub · Feb 5, 2025 · 48 reactions
- quarkusio/quarkus“Sentry tracing with automatic instrumentation”GitHub · Aug 31, 2021 · 19 reactions
- getsentry/sentry-dart“Support Source Context”GitHub · Oct 25, 2020 · 18 reactions
- getsentry/sentry-dotnet“OpenTelemetry Support”GitHub · Nov 25, 2022 · 11 reactions
- getsentry/sentry-dotnet“Feature: Session Replay support for .NET MAUI”GitHub · Jan 30, 2023 · 8 reactions
The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 18
Talked about on GitHub (18 times).
On GitHub · 18
- Feb 5, 2025[Mobile Replay] Capture Network request/response bodies — getsentry/sentry48 reactions · 13 comments
- Aug 31, 2021Sentry tracing with automatic instrumentation — quarkusio/quarkus19 reactions · 20 comments
- Oct 25, 2020Support Source Context — getsentry/sentry-dart18 reactions · 24 comments
- Nov 25, 2022OpenTelemetry Support — getsentry/sentry-dotnet11 reactions · 4 comments
- Jan 30, 2023Feature: Session Replay support for .NET MAUI — getsentry/sentry-dotnet8 reactions · 9 comments
13 more on GitHub
- Mar 19, 2025Add UI Profiling Support (converted to project) — getsentry/sentry-react-native5 reactions · 3 comments
- Jan 20, 2021Proposal (Performance): Some convenience API to wrap a Promise with a Span/Transaction — getsentry/sentry-javascript5 reactions · 2 comments
- May 1, 2025feat: Initial Android support — getsentry/sentry-godot4 reactions · 3 comments
- Mar 25, 2024feat(replay): Add Mobile Replay Alpha — getsentry/sentry-react-native4 reactions · 8 comments
- Feb 8, 2023Add support for Sentry — spring-io/start.spring.io4 reactions · 6 comments
- May 4, 2022Figure out how to implement hints — getsentry/sentry-javascript4 reactions · 5 comments
- Dec 10, 2020Add basic support for attachments — getsentry/sentry-cocoa4 reactions
- Jul 17, 2025Bump io.sentry.android.gradle from 4.10.0 to 5.8.0 — woocommerce/woocommerce-android3 reactions · 2 comments
- Jul 23, 2024feat: User Feedback widget/form — getsentry/sentry-cocoa3 reactions · 5 comments
- May 1, 2024Remove `enableTracing` (and update docs accordingly) — getsentry/team-sdks3 reactions · 7 comments
- Feb 1, 2024[Epic] Mobile Session Replay — getsentry/sentry3 reactions · 2 comments
- Nov 20, 2023Tracing: W3C Trace Context Support — getsentry/team-sdks3 reactions · 9 comments
- Jan 12, 2023Allow more granular auto installation — getsentry/sentry-android-gradle-plugin3 reactions · 3 comments
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/api.mdcCursor rule
- .cursor/rules/continuous_profiling_jvm.mdcCursor rule
- .cursor/rules/deduplication.mdcCursor rule
- .cursor/rules/e2e_tests.mdcCursor rule
- .cursor/rules/feature_flags.mdcCursor rule
- .cursor/rules/metrics.mdcCursor rule
- .cursor/rules/new_module.mdcCursor rule
- .cursor/rules/opentelemetry.mdcCursor rule
- .cursor/rules/options.mdcCursor rule
- .cursor/rules/queues.mdcCursor rule
- .cursor/rules/scopes.mdcCursor rule
- btrace-perfettoSkill
- check-code-attributionSkill
- create-java-prSkill
- testSkill
The file
We split this offline.mdc into the rules it gives an agent
12 rules. About 0 are common, 4 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
If an envelope is dropped due to rate limit and has previously been cached (Cached hint) it will be discarded from the IEnvelopeCache.
- Distinctive: line 24
If the envelope is not retryable and hasn't been sent to offline cache, it's recorded as lost in a client report.
- Distinctive: line 27
If it's not retryable and hasn't been cached, it's recorded as lost in a client report.
- Very specific: line 45
When AsyncHttpTransport successfully sends an envelope to the Sentry server, it calls envelopeCache.discard(envelope) to remove the cached …
- Very specific: line 48
If an envelope is dropped due to rate limiting and has previously been cached (indicated by the Cached hint), it gets discarded immediately …
- Very specific: line 52
When the SDK processes cached envelope files from disk (via EnvelopeSender), files are deleted after processing unless they are marked for …
- Very specific: line 58
If the number of files in the cache directory has reached the configured limit (SentryOptions.maxCacheItems), the oldest file will be …
- Distinctive: line 67
Non-retryable envelopes: If they fail to send, they're immediately recorded as lost (not cached for retry)
- Very specific: line 71
Queue Overflow: When the transport executor queue is full - recorded as DiscardReason.QUEUE_OVERFLOW
- Very specific: line 73
Network Errors (Non-Retryable): When an envelope isn't marked as retryable and fails due to network issues - recorded as …
- Very specific: line 75
Rate Limiting: When envelope items are dropped due to active rate limits - recorded as DiscardReason.RATELIMIT_BACKOFF
- Very specific: line 77
Cache Overflow: When the cache directory has reached maxCacheItems, old files are deleted - recorded as DiscardReason.CACHE_OVERFLOW
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
--- alwaysApply: false description: Java SDK Offline behaviour --- # Java SDK Offline behaviour By default offline caching is enabled for Android but disabled for JVM. It can be enabled by setting SentryOptions.cacheDirPath. For Android, AndroidEnvelopeCache is used. For JVM, if cache path has been configured, EnvelopeCache will be used. Any error, event, transaction, profile, replay etc. is turned into an envelope and then sent into ITransport.send. The default implementation is AsyncHttpTransport. If an envelope is dropped due to rate limit and has previously been cached (Cached hint) it will be discarded from the IEnvelopeCache. AsyncHttpTransport.send will enqueue an AsyncHttpTransport.EnvelopeSender task onto an executor. Any envelope that doesn't have the Cached hint will be stored in IEnvelopeCache by the EventSender task. Previously cached envelopes (Cached hint) will have a noop cache passed to AsyncHttpTransport.EnvelopeSender and thus not cache again. It is also possible cache is disabled in general. An envelope being sent directly from SDK API like Sentry.captureException will not have the Retryable hint. In case the SDK is offline, it'll mark the envelope to be retried if it has the Retryable hint. If the envelope is not retryable and hasn't been sent to offline cache, it's recorded as lost in a client report. In case the envelope can't be sent due to an error or network connection problems it'll be marked for retry if it has the Retryable hint. If it's not retryable and hasn't been cached, it's recorded as lost in a client report. In case the envelope is sent successfully, it'll be discarded from cache. The SDK has multiple mechanisms to deal with envelopes on disk. - OutboxSender: Sends events coming from other SDKs like NDK that wrote them to disk. - io.sentry.EnvelopeSender: This is the offline cache. Both of these are set up through an integration (SendCachedEnvelopeIntegration) which is configured to use SendFireAndForgetOutboxSender or SendFireAndForgetEnvelopeSender. io.sentry.EnvelopeSender is able to pick up files in the cache directory and send them. It will trigger sending envelopes in cache dir on init and when the connection status changes (e.g. the SDK comes back online, meaning it has Internet connection again). ## When Envelope Files Are Removed From Cache Envelope files are removed from the cache directory in the following scenarios: ### 1. Successful Send to Sentry Server When `AsyncHttpTransport` successfully sends an envelope to the Sentry server, it calls `envelopeCache.discard(envelope)` to remove the cached file. This happens in `AsyncHttpTransport.EnvelopeSender.flush()` when `result.isSuccess()` is true. ### 2. Rate Limited Previously Cached Envelopes If an envelope is dropped due to rate limiting **and** has previously been cached (indicated by the `Cached` hint), it gets discarded immediately via `envelopeCache.discard(envelope)` in `AsyncHttpTransport.send()`. In this case the discarded envelope is recorded as lost in client reports. ### 3. Offline Cache Processing (EnvelopeSender) When the SDK processes cached envelope files from disk (via `EnvelopeSender`), files are deleted after processing **unless** they are marked for retry. In `EnvelopeSender.processFile()`, the file is deleted with `safeDelete(file)` if `!retryable.isRetry()`. ### 4. Session File Management Session-related files (session.json, previous_session.json) are removed during session lifecycle events like session start/end and abnormal exits. ### 5. Cache rotation If the number of files in the cache directory has reached the configured limit (SentryOptions.maxCacheItems), the oldest file will be deleted to make room. This happens in `CacheStrategy.rotateCacheIfNeeded`. The deleted envelope will be recorded as lost in client reports. ## Retry Mechanism **Important**: The SDK does NOT implement a traditional "max retry count" mechanism. Instead: ### Infinite Retry Approach - **Retryable envelopes**: Stay in cache indefinitely and are retried when conditions improve (network connectivity restored, rate limits expire, etc.) - **Non-retryable envelopes**: If they fail to send, they're immediately recorded as lost (not cached for retry) ### When Envelopes Are Permanently Lost (Not Due to Retry Limits) 1. **Queue Overflow**: When the transport executor queue is full - recorded as `DiscardReason.QUEUE_OVERFLOW` 2. **Network Errors (Non-Retryable)**: When an envelope isn't marked as retryable and fails due to network issues - recorded as `DiscardReason.NETWORK_ERROR` 3. **Rate Limiting**: When envelope items are dropped due to active rate limits - recorded as `DiscardReason.RATELIMIT_BACKOFF` 4. **Cache Overflow**: When the cache directory has reached maxCacheItems, old files are deleted - recorded as `DiscardReason.CACHE_OVERFLOW` ### Cache Processing Triggers Cached envelopes are processed when: - Network connectivity is restored (via connection status observer) - SDK initialization occurs - Rate limits expire - Manual flush operations ### File Deletion Implementation The actual file deletion is handled by `EnvelopeCache.discard()` which calls `envelopeFile.delete()` and logs errors if deletion fails.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

