Skip to content

fix(core): [Callback Errors 6] Handle profilesSampler failures - #6164

Draft
adinauer wants to merge 3 commits into
fix/callback-error-handling-traces-samplerfrom
fix/callback-error-handling-profiles-sampler
Draft

adinauer wants to merge 3 commits into
fix/callback-error-handling-traces-samplerfrom
fix/callback-error-handling-profiles-sampler

Conversation

@adinauer

@adinauer adinauer commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Callback Errors)


📜 Description

Disable profiling when profilesSampler throws, without changing trace sampling. Skip the configured profilesSampleRate and do not inherit a parent's profiling decision after callback failure.

The parent path preserves the trace sampling decision, trace sample rate, and sample-random value, including backfilling when needed. It does not mutate the original parent decision. A callback deliberately returning null still uses the existing fallback behavior. Error logging and catch types are unchanged.

If tracesSampler also throws, the failure behavior from #6163 disables both tracing and profiling regardless of the parent's decision. Its immediate callback_error reports and accepted duplicate sampling-loss reports remain unchanged.

💡 Motivation and Context

A failed profiling callback must not enable profiling through a static rate or parent inheritance. Returning the parent's entire sampling decision would bypass the local failure result and could re-enable profiling, so the failure path retains only the parent's trace fields.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • Original focused validation passed 395 tests; all four original regression tests failed before the production fix and passed afterward.
  • After merging the updated fix(core): [Callback Errors 5] Handle tracesSampler failures #6163, reran TracesSamplerTest, ScopesTest, OpenTelemetry SentrySamplerTest, and the core API check successfully.
  • Covered absent/zero/full static profile rates with zero sample-random value, a working trace sampler after profiling failure, sampled and unsampled parents, and both samplers failing despite a sampled parent.
  • Updated existing null-result tests to invoke callbacks actually returning null.
  • After merge-forward through fix(integrations): [Callback Errors 9] Guard custom callbacks #6167, 3,814 core/OpenTelemetry tests passed, along with formatting and API checks.

📝 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 discard accounting is handled separately in #6166. Profile/replay artifact cleanup remains a follow-up. The broader 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.

Disable profiling when profilesSampler throws instead of applying the
static profilesSampleRate or inheriting a parent profiling decision.
Preserve trace sampling metadata and normal null-result fallback.

Cover static-rate bypass, parent inheritance, and failures in both
samplers without changing existing catch types.

Refs #6081

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

sentry Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

Link the profilesSampler failure handling entry to #6164 in the callback
error handling stack.
Merge the updated tracesSampler failure behavior from #6163 into #6164.
Preserve profile-sampler isolation and update the combined-failure test to
expect tracing and profiling to be disabled, even with a sampled parent.

Refs #6163
Refs #6164
Co-Authored-By: Claude <noreply@anthropic.com>
adinauer added a commit that referenced this pull request Sep 25, 2026
Merge #6164 forward into #6165 without rewriting stack history.
Retain replay sampling changes and the updated trace-sampler changelog.

Refs #6165
Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant