From e6486b9c12ba21a06d6634a2174245c458356a4c Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Thu, 2 Jul 2026 18:50:54 +0200 Subject: [PATCH] perf(core): Skip redundant setBreadcrumbs call on add path (JAVA-606) addBreadcrumb notified each scope observer twice: addBreadcrumb(crumb) followed by setBreadcrumbs(all). For PersistingScopeObserver the second call is a no-op right after an add (it only acts when the collection is empty), yet still acquires the synchronized-queue lock and re-iterates observers on every breadcrumb. Notify observers once per add. Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 6 ++++++ sentry/src/main/java/io/sentry/Scope.java | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a290e2b3e..0f718d4b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Performance + +- Notify scope observers once per breadcrumb by dropping the redundant `setBreadcrumbs` call on the `Scope.addBreadcrumb` path ([#5690](https://github.com/getsentry/sentry-java/pull/5690)) + ## 8.47.0 ### Behavioral Changes diff --git a/sentry/src/main/java/io/sentry/Scope.java b/sentry/src/main/java/io/sentry/Scope.java index 282fc4df67..43f620c188 100644 --- a/sentry/src/main/java/io/sentry/Scope.java +++ b/sentry/src/main/java/io/sentry/Scope.java @@ -506,7 +506,6 @@ public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) { for (final IScopeObserver observer : options.getScopeObservers()) { observer.addBreadcrumb(breadcrumb); - observer.setBreadcrumbs(breadcrumbs); } } else { options.getLogger().log(SentryLevel.INFO, "Breadcrumb was dropped by beforeBreadcrumb");