Skip to content

Optimize when maxBreadcrumb is 0 #4504

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

stefanosiano
Copy link
Member

📜 Description

breadcumbs queue is now a simple DisabledQueue when maxBreadcrumb is 0
if breadcumbs is a DisabledQueue, no more processing is done (beforeBreadcrumb or scopeObservers)

💡 Motivation and Context

Fixes #4334
Previously we were calling beforeBreadcrumb and scopeObservers even when maxBreadcrumbs was 0, which was useless

💚 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

stefanosiano and others added 5 commits June 20, 2025 12:43
if breadcumbs is a DisabledQueue, no more processing is done (beforeBreadcrumb or scopeObservers)
added test
…ations' into fix/disabled-breadcrumbs-optimizations
@@ -862,7 +862,7 @@ public void clearAttachments() {
static @NotNull Queue<Breadcrumb> createBreadcrumbsList(final int maxBreadcrumb) {
return maxBreadcrumb > 0
? SynchronizedQueue.synchronizedQueue(new CircularFifoQueue<>(maxBreadcrumb))
: SynchronizedQueue.synchronizedQueue(new DisabledQueue<>());
: new DisabledQueue<>();
Copy link
Member Author

Choose a reason for hiding this comment

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

I tried calling queue.add from multiple threads concurrently, and it didn't crash, so i think we it's fine to remove SynchronizedQueue

@stefanosiano stefanosiano marked this pull request as ready for review June 20, 2025 10:57
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 460.76 ms 492.36 ms 31.60 ms
Size 1.58 MiB 2.09 MiB 518.69 KiB

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.

Setting maxBreadcrumbs 0 and beforeBreadcrumb callback crash
2 participants