Skip to content

fix(core): [Callback Errors 8] Report dropped profiles - #6166

Merged
adinauer merged 11 commits into
fix/callback-error-handlingfrom
fix/callback-error-handling-profile-accounting
Oct 8, 2026
Merged

adinauer merged 11 commits into
fix/callback-error-handlingfrom
fix/callback-error-handling-profile-accounting

Conversation

@adinauer

@adinauer adinauer commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Callback Errors)


📜 Description

Record one callback_error/profile loss when an attached transaction profile is dropped because beforeSendTransaction or a customer event processor throws. The same accounting path notifies OnDiscardCallback.

Pass profile presence into the private transaction-processing helpers so scope and options processors both account for the loss. Transactions without profiles do not report profile losses. SDK processor failures continue sending the transaction and attached profile without reporting a loss.

Existing transaction/span accounting, intentional-drop behavior, and catch types are unchanged. This does not change profile-file cleanup or continuous profile chunks.

💡 Motivation and Context

Transaction callback failures already record the lost transaction and spans, but omit an attached profile that is dropped with them. Include that profile so client reports and discard observers reflect the full loss.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:apiCheck :sentry:spotlessCheck :sentry:test --tests='*SentryClientTest*' --tests='*SentryClientTransactionProfileTest*' --tests='*SentryClientInternalEventProcessorTest*' --tests='*ClientReportTest*' --info — 295 tests passed
  • All three attached-profile failure cases failed before the production fix and passed afterward.
  • Cover scope processors, options processors, and beforeSendTransaction, each with and without an attached profile. Assert exact client-report counts and discard notifications.
  • Verify SDK processor exceptions retain the attached profile and report no losses for both registration paths.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Profile/replay artifact cleanup remains a separate follow-up. Callback-boundary catch-type changes remain deferred to the next major.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Record callback_error/profile when beforeSendTransaction or a customer
transaction processor throws and an attached profile is dropped. Notify
OnDiscardCallback through the same client-report accounting path.

Cover scope and options processors, absent profiles, and SDK processor
failures that retain profiles. Leave catch types, intentional drops,
and profile-file cleanup unchanged.

Refs #6081
Co-Authored-By: Claude <noreply@anthropic.com>
Link the transaction profile loss accounting entry to PR #6166.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.59.0 (1) release

⚙️ sentry-android Build Distribution Settings

Skip Android screenshot and view hierarchy capture when their callbacks
throw, while retaining the error event. Drop spans on beforeSpan failures
in OkHttp, OpenFeign, GraphQL, Ktor, and Apollo without disrupting requests
or replacing the original request error.

Preserve normal callback results and existing catch types. Finish failed
spans and retain request cleanup and breadcrumbs.

Add regression coverage for callback failures, partial mutations, original
request errors, asynchronous GraphQL results, and subsequent Android
captures. Correct callback wiring in the Ktor and screenshot test fixtures.

Verify 18 regression cases fail before the fix and pass afterward; all 454
tests in the affected suites pass, along with formatting and API checks.

Refs #6081

Co-Authored-By: Claude <noreply@anthropic.com>
adinauer and others added 4 commits September 25, 2026 07:00
Link the Android capture and integration beforeSpan callback fixes to
Callback Errors 9 (#6167).

Co-Authored-By: Claude <noreply@anthropic.com>
Merge #6165 forward into #6166 without rewriting stack history.
Preserve attached-profile loss accounting alongside the sampler fixes.

Refs #6166
Co-Authored-By: Claude <noreply@anthropic.com>
Merge #6166 forward into #6167 without rewriting stack history.
Preserve integration callback guards alongside the updated sampler behavior.

Validate the combined core and OpenTelemetry suites, formatting, and API checks.

Refs #6167
Co-Authored-By: Claude <noreply@anthropic.com>
Record callback_error/span when a throwing beforeSpan callback drops a
sampled span in OkHttp, OpenFeign, GraphQL, Ktor, and Apollo. Use the
pre-callback sampling decision so partial callback mutations do not hide
losses, and leave unsampled spans and intentional null drops uncounted.

Add regression coverage for discard notifications, sampling states, and
intentional drops while preserving request and span completion behavior.

Refs #6167
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread sentry/src/main/java/io/sentry/SentryClient.java

@romtsn romtsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one Q, LGTM otherwise

adinauer and others added 4 commits October 8, 2026 10:00
Record attached profiles as lost when transaction event processors or
beforeSendTransaction intentionally discard the transaction. Keep client
reports and discard callbacks aligned with dropped profile payloads.

Co-Authored-By: Claude <noreply@anthropic.com>
Propagate the latest main and preceding callback error changes through the stacked pull request.

Co-Authored-By: Claude <noreply@anthropic.com>
Propagate the latest main and preceding callback error changes through the stacked pull request.

Co-Authored-By: Claude <noreply@anthropic.com>
…ustom-callbacks

fix(integrations): [Callback Errors 9] Guard custom callbacks
Base automatically changed from fix/callback-error-handling-replay-sampling to fix/callback-error-handling October 8, 2026 10:55
@adinauer
adinauer marked this pull request as ready for review October 8, 2026 10:55
@adinauer
adinauer merged commit dfb67ed into fix/callback-error-handling Oct 8, 2026
63 of 65 checks passed
@adinauer
adinauer deleted the fix/callback-error-handling-profile-accounting branch October 8, 2026 10:56
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Fixes

- [Callback Errors 8] Report dropped profiles ([#6166](https://github.com/getsentry/sentry-java/pull/6166))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 64c1c55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 64c1c55. Configure here.

DiscardReason.CALLBACK_ERROR,
DataCategory.Span,
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apollo 5 skips span drop

Medium Severity

beforeSpan failures now drop the span and record callback_error in Apollo 2/3/4, OkHttp, OpenFeign, GraphQL, and Ktor, but SentryApollo5HttpInterceptor still only logs and sends the span. Apollo 5 callers keep a partially processed span and never notify OnDiscardCallback.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 64c1c55. Configure here.

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.

2 participants