Skip to content

fix: isolate TracesSampler callback failures - #5545

Merged
jamescrosswell merged 2 commits into
getsentry:mainfrom
elkampu:elkampu/fix-traces-sampler-isolation-5535
Sep 9, 2026
Merged

fix: isolate TracesSampler callback failures#5545
jamescrosswell merged 2 commits into
getsentry:mainfrom
elkampu:elkampu/fix-traces-sampler-isolation-5535

Conversation

@elkampu

@elkampu elkampu commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Addresses the TracesSampler portion of #5535.

What changed

  • isolate managed TracesSampler failures at the user-callback boundary and log TracesSampler callback failed. at error level
  • return to the existing unconfigured-sampler fallback path, preserving inherited decisions before TracesSampleRate
  • keep SDK-owned backpressure, random sampling, discard-reason, and DSC logic outside the recovery boundary
  • apply the same callback isolation to the Android JNI and Cocoa native bridges, returning null on callback failure so the native SDK can use its normal fallback
  • add managed regressions for static sample-in/sample-out, inherited sampled-in/sampled-out, exact error logging, and normal sample_rate client-report accounting

Validation

  • dotnet test test/Sentry.Tests/Sentry.Tests.csproj -c Release -f net10.0 --filter "FullyQualifiedName~StartTransaction_TracesSampler" --no-restore — 10/10 passed
  • dotnet build src/Sentry/Sentry.csproj -c Release -f net10.0 --no-restore — passed, 0 warnings/errors
  • dotnet build src/Sentry/Sentry.csproj -c Release -f net10.0-android36.0 --no-restore — passed, 0 warnings/errors
  • scoped dotnet format whitespace --folder --verify-no-changes for the five changed files — passed
  • git diff --check — passed

Cocoa compilation requires macOS; the Cocoa change is limited to the same user-delegate recovery boundary and will be exercised by the repository's macOS CI.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 7, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.76%. Comparing base (98a6f8d) to head (2c705db).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5545      +/-   ##
==========================================
+ Coverage   74.70%   74.76%   +0.05%     
==========================================
  Files         515      515              
  Lines       18948    18963      +15     
  Branches     3696     3694       -2     
==========================================
+ Hits        14155    14177      +22     
+ Misses       3909     3908       -1     
+ Partials      884      878       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the help @elkampu!

This looks 99% of the way there. I've just made one small suggestion.

Comment thread src/Sentry/Platforms/Android/Callbacks/TracesSamplerCallback.cs Outdated
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
@jamescrosswell
jamescrosswell self-requested a review September 9, 2026 00:28

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @elkampu - much appreciated!

@jamescrosswell
jamescrosswell merged commit 9683c36 into getsentry:main Sep 9, 2026
44 checks passed
This was referenced Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants