Conversation
Add the callback_error discard reason and use it when a beforeSend callback throws. Preserve before_send for callbacks that intentionally return null and retain item, span, and byte accounting. Refs #6081 Co-Authored-By: Claude <noreply@anthropic.com>
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- [Callback Errors 1] Report callback failures ([#6141](https://github.com/getsentry/sentry-java/pull/6141))If none of the above apply, you can opt out of this check by adding |
📲 Install BuildsAndroid
|
There was a problem hiding this comment.
We should check if/how we should be logging these failures against the spec.
The spec should also clarify if non-recoverable errors should be swallowed. I don't think non-recoverable errors should be swallowed since they aren't recoverable and make it harder for customers to debug real issues.
| final int spanCountAfterCallback = transaction.getSpans().size(); | ||
| if (spanCountAfterCallback < spanCountBeforeCallback) { | ||
| final int droppedSpanCount = spanCountBeforeCallback - spanCountAfterCallback; | ||
| options |
There was a problem hiding this comment.
I don't know if I'm understanding the spec correctly. I see different interpretations available.
It says On failure, SDKs **MUST** emit an error-level internal log together with failure **MUST NOT** produce a billed event of any type.
Its unclear what "internal log" exactly means but isn't calling log a billable event?
Aside from being a billable event, it can also lead to failures because we have a BeforeSendLogCallback.
PR Stack (Callback Errors)
📜 Description
Adds
DiscardReason.CALLBACK_ERRORand uses it when an existingbeforeSend*callback throws and drops telemetry. Intentionalnullreturns continue to usebefore_send.The change preserves transaction/root-span and log/metric byte accounting, and exposes the new reason through
OnDiscardCallback.💡 Motivation and Context
Callback failures and intentional filtering currently share the same discard reason. Distinguishing them makes client reports and local discard observers accurately describe why telemetry was dropped.
💚 How did you test it?
./gradlew spotlessApply apiDump./gradlew :sentry:test --tests io.sentry.SentryClientTest --tests io.sentry.clientreport.ClientReportTest./gradlew :sentry:apiCheck📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
The next stack PR (#6162) marks SDK-owned event processors, followed by event processor exception handling in #6142.