Skip to content

Do not report cached events as lost #4575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 8, 2025

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Jul 29, 2025

📜 Description

Do not report cached events as lost

💡 Motivation and Context

Fixes #4568

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link
Member Author

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

Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

Copy link
Contributor

github-actions bot commented Jul 29, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 445.50 ms 446.58 ms 1.08 ms
Size 1.58 MiB 2.09 MiB 522.31 KiB

Previous results on branch: 07-29-do_not_report_cached_events_as_lost

Startup times

Revision Plain With Sentry Diff
4bd0f22 395.69 ms 448.04 ms 52.35 ms
972727c 393.16 ms 434.53 ms 41.37 ms
d4dcd6e 399.34 ms 421.18 ms 21.84 ms
020c051 431.22 ms 470.64 ms 39.42 ms

App size

Revision Plain With Sentry Diff
4bd0f22 1.58 MiB 2.09 MiB 522.32 KiB
972727c 1.58 MiB 2.09 MiB 519.50 KiB
d4dcd6e 1.58 MiB 2.09 MiB 522.31 KiB
020c051 1.58 MiB 2.09 MiB 519.63 KiB

* e2e tests for console app

* fix test failures by waiting for 10s after first try to find envelopes

* add system-test-runner.py script to replace bash scripts for running e2e / system tests

* use py script for ci, cleanup, makefile

* Format code

* remove bash scripts

* install requests module

* api

* fix gh script

* Implement E2E tests for OTel based console sample

* fixes after merge

* Format code

* e2e tests for console app

* Implement E2E tests for OTel based console sample

* fixes after merge

* Format code

* api

* Reduce scope forking when using OpenTelemetry (#4565)

* Reduce scope forking in OpenTelemetry

* Format code

* api

* changelog

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>

* SDKs send queue is no longer shutdown immediately on re-init (#4564)

* Let queue drain on a restart

* Format code

* Format code

* Update sentry-samples/sentry-samples-console-opentelemetry-noagent/src/test/kotlin/sentry/systemtest/ConsoleApplicationSystemTest.kt

* Let queue drain on a restart

* Format code

* Format code

* Update sentry-samples/sentry-samples-console-opentelemetry-noagent/src/test/kotlin/sentry/systemtest/ConsoleApplicationSystemTest.kt

* adapt tests

* changelog

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

@@ -268,7 +268,7 @@ public void run() {
TransportResult result = this.failedResult;

envelope.getHeader().setSentAt(null);
envelopeCache.store(envelope, hint);
boolean cached = envelopeCache.storeEnvelope(envelope, hint);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since envelopes that were cached previously have a no-op envelope cache here inEnvelopeSender, this will be false for envelopes sent from cache.

@adinauer adinauer marked this pull request as ready for review July 30, 2025 14:59
Copy link
Contributor

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

cursor[bot]

This comment was marked as outdated.

void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint);

default boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also explicitly implement it in AndroidEnvelopeCache? I recall there were some issues with desugaring on Unity, where it would crash with NoSuchMethodError for default methods in core sentry

void store(@NotNull SentryEnvelope envelope, @NotNull Hint hint);

default boolean storeEnvelope(@NotNull SentryEnvelope envelope, @NotNull Hint hint) {
store(envelope, hint);
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should actually return false in case an envelope couldn't be stored here, wdyt? Could be because of no storage space, for example.

Copy link
Member

@romtsn romtsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two comments that I think need to be addressed before merging this:

  • Implement storeEnvelope in AndroidEnvelopeCache
  • Return false for the case where an envelope could not be stored due to FileSystem issues

getsentry-bot and others added 12 commits August 8, 2025 11:26
* fix(android): Remove unused method

* Update Changelog
#skip-changelog

## 📜 Description
<!--- Describe your changes in detail -->
Add rules file for documenting SDK offline behaviour

## 💡 Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Should help speed up AI reasoning about the SDK offline/retry behaviour.

## 💚 How did you test it?


## 📝 Checklist
<!--- Put an `x` in the boxes that apply -->

- [ ] I added tests to verify the changes.
- [ ] No new PII added or SDK only sends newly added PII if `sendDefaultPII` is enabled.
- [ ] I updated the docs if needed.
- [ ] I updated the wizard if needed.
- [ ] Review from the native team if needed.
- [ ] No breaking change or entry added to the changelog.
- [ ] No breaking change for hybrid SDKs or communicated to hybrid SDKs.


## 🔮 Next steps
* fix: sentry-androi-ndk proguard rule keeps all native class

* docs: update CHANGELOG

* fix: update CHANGELOG

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Markus Hintersteiner <m.hintersteiner@gmail.com>
Co-authored-by: Markus Hintersteiner <markus.hintersteiner@sentry.io>
* perf(connectivity): Cache network capabilities and status to reduce IPC calls

* changelog

* Changelog

* revert

* fix(breadcrumbs): Deduplicate battery breadcrumbs

* ref

* Changelog

* Fix test

* perf(connectivity): Have only one NetworkCallback active at a time

* Changelog

* perf(integrations): Use single lifecycle observer

* Add tests

* Changelog

* Fix tests

* Improve callback handling and test visibility (#4593)

* Null-check lifecycleObserver

---------

Co-authored-by: Markus Hintersteiner <markus.hintersteiner@sentry.io>
* fix(sqlite): Fix abstract method error

* Update CHANGELOG.md

* Suppress metadata version checks
romtsn and others added 5 commits August 8, 2025 11:26
…red on the main thread (#4582)

* fix(android): Ensure frame metrics listeners are registered/unregistered on the main thread

* Fix race conditions

* Update Changelog

* Update CHANGELOG.md

* Address PR feedback
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Aug 8, 2025

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

Copy link
Contributor

github-actions bot commented Aug 8, 2025

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

Copy link
Contributor

github-actions bot commented Aug 8, 2025

🚨 Detected changes in high risk code 🚨

High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:

  • sentry/src/main/java/io/sentry/transport/AsyncHttpTransport.java

default void store(@NotNull SentryEnvelope envelope) {
store(envelope, new Hint());
storeEnvelope(envelope, new Hint());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cache Store Failure Masking

The default implementation of IEnvelopeCache.storeEnvelope() always returns true, even if a custom implementation of the deprecated store(SentryEnvelope, Hint) method fails silently. This incorrectly indicates successful caching. Furthermore, the deprecated store(SentryEnvelope) method calls storeEnvelope() but ignores its boolean return value, masking storage failures for callers still using this API.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to maintain backward compatibility and thus cannot replace the method directly. We are overriding storeEnvelope in both EnvelopeCache and AndroidEnvelopeCache to avoid this problem.

@adinauer adinauer merged commit e2b7f44 into main Aug 8, 2025
37 checks passed
@adinauer adinauer deleted the 07-29-do_not_report_cached_events_as_lost branch August 8, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client reports record lost envelopes when offline and the envelope is retried later
5 participants