Skip to content

ref(core): Remove deprecated traceSampling option - #6415

Merged
adinauer merged 5 commits into
9.x.xfrom
ref/remove-trace-sampling-option
Nov 12, 2026
Merged

adinauer merged 5 commits into
9.x.xfrom
ref/remove-trace-sampling-option

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

📜 Description

Removes the traceSampling option for 9.0:

  • SentryOptions.isTraceSampling() / setTraceSampling(boolean) and the backing field
  • Android manifest key io.sentry.traces.trace-sampling (ManifestMetadataReader.TRACE_SAMPLING)
  • The isTraceSampling() gates in SentryTracer and OtelSpanWrapper (traceContext() / toBaggageHeader()), TracingUtils.traceIfAllowed, and SentryApolloInterceptor
  • Tests that only covered the option being disabled, plus isTraceSampling = true setup lines that matched the default

After this change:

  • traceContext() and toBaggageHeader() return a value whenever the transaction has baggage.
  • tracePropagationTargets is the only setting that controls outgoing sentry-trace/baggage headers.

💡 Motivation and Context

traceSampling has defaulted to true since 6.5.0-beta.2 (#2255). The getter is @ApiStatus.Experimental, the setter is @Deprecated in favor of tracePropagationTargets, and both Javadocs say "will be removed without notice". Even so, it still worked as a hidden switch for trace propagation in core, OpenTelemetry, Apollo and Android. Removing it leaves one supported way to control propagation.

Behavior change for anyone who set it to false:

  • Outgoing HTTP: they can get the same result with an empty tracePropagationTargets. Apollo is the exception, because it calls TracingUtils.trace directly and has no URL to match against.
  • Envelopes: there is no replacement for dropping the envelope trace header. Transactions with baggage always attach it now.

💚 How did you test it?

Ran locally on JDK 21:

  • :sentry:test: TracingUtilsTest, SentryTracerTest, SpanTest, SentryClientTest
  • :sentry-opentelemetry:sentry-opentelemetry-core:test
  • :sentry-openfeign:test
  • SentrySpanRest*CustomizerTest in sentry-spring-boot, sentry-spring-boot-jakarta and sentry-spring-boot-4
  • :sentry-apollo:compileKotlin
  • :sentry:apiDump, plus spotlessApply on the changed JVM modules

No Android SDK was available in the sandbox, so sentry-android-core (ManifestMetadataReader and its test) was not built locally. That change only deletes lines plus the now-unused ApiStatus import. CI should cover it.

📝 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

  • Decide whether 9.0 needs a replacement switch for dropping the envelope trace header. I don't think it does, but I'd like a reviewer to confirm.
  • Check whether hybrid SDKs (RN, Flutter, Unity, etc.) set traceSampling / io.sentry.traces.trace-sampling.
  • Update the docs and the 9.0 migration guide where the option is mentioned.

via alexander.dinauer.

--

View Junior Session [Sentry]

sentry-junior Bot and others added 2 commits October 29, 2026 09:52
Remove SentryOptions.isTraceSampling/setTraceSampling and the
io.sentry.traces.trace-sampling Android manifest key. The option has
defaulted to true since 6.5.0 and was marked experimental and deprecated
in favor of tracePropagationTargets. Trace context and baggage are now
always produced when a transaction has baggage, and outgoing tracing
headers are controlled by tracePropagationTargets alone.

Co-Authored-By: Alexander Dinauer <alexander.dinauer@sentry.io>
Co-Authored-By: Alexander Dinauer <alexander.dinauer@sentry.io>
@sentry

sentry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

The mocked SentryOptions used to return false for isTraceSampling, which
skipped baggage computation on transaction finish. With the option
removed, SentryTracer always fills baggage values and needs a parsed DSN.

@romtsn romtsn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! I agree we don't need a replacement switch for the trace header.

And one thing re. Apollo: theoretically, we could add Apollo span origins to ignoredSpanOrigins to stop creating headers, but it will also stop creating spans. Not sure if we should do it, but if we do, we need to add it to the migration guide.

@adinauer
adinauer marked this pull request as ready for review November 10, 2026 10:26
@adinauer
adinauer requested review from a team and adinauer as code owners November 10, 2026 10:26
@adinauer
adinauer requested review from 0xadam-brown and markushi and removed request for a team November 10, 2026 10:26
Resolve the changelog and Apollo interceptor conflicts while preserving
Apollo's attachTracingHeaders option and removing the deprecated
traceSampling gate. Remove stale test setup added on the base branch.

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

Copy link
Copy Markdown
Member

@romtsn we recently merged a community PR to add an extra flag for the integration, that allows opting out of the headers separately. I'll expand the changelog entry and migration guide.

Distinguish URL-aware propagation targets from Apollo v2 and document
its attachTracingHeaders opt-out, which preserves span creation.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer merged commit fb3e477 into 9.x.x Nov 12, 2026
45 of 49 checks passed
@adinauer
adinauer deleted the ref/remove-trace-sampling-option branch November 12, 2026 10:07
adinauer added a commit that referenced this pull request Nov 12, 2026
…shed (#6595)

#6417 replaced Span.getOptions() with Span.isIdle(), but #6415 merged
right after and brought back the old span.getOptions().isIdle() call,
so 9.x.x no longer compiles.

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Alexander Dinauer <alexander.dinauer@sentry.io>
adinauer added a commit to getsentry/sentry-docs that referenced this pull request Nov 12, 2026
## DESCRIBE YOUR PR

Document the removal of the deprecated `traceSampling` option in the
Java and Android v8-to-v9 migration guides.

The guidance explains how to disable outgoing trace headers with
`tracePropagationTargets`, how Apollo v2 users can opt out, and that
envelope trace context can no longer be suppressed through this option.

This PR targets the `java-v9` collection branch so the migration
guidance publishes with SDK v9.

Refs getsentry/sentry-java#6415

## IS YOUR CHANGE URGENT?

- [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD
- [ ] Other deadline: YYYY-MM-DD
- [x] No deadline: Not urgent, can wait up to 1 week+

---------

Co-authored-by: OpenAI <noreply@openai.com>
Co-authored-by: Claude <noreply@anthropic.com>
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