Repository navigation
fix!(core): Distinguish disabled traces sampling strategy - #1227
Merged
szokeasaurusrex merged 2 commits intoJul 21, 2026
Merged
szokeasaurusrex merged 2 commits into
szokeasaurusrex merged 2 commits into
Conversation
szokeasaurusrex
force-pushed
the
szokeasaurusrex/traces-sampling-strat
branch
2 times, most recently
from
July 7, 2026 12:36
d9beb1d to
1bdc841
Compare
szokeasaurusrex
force-pushed
the
szokeasaurusrex/traces-sampling-strat
branch
from
July 8, 2026 13:56
d8e15af to
b34aaa6
Compare
szokeasaurusrex
changed the base branch from
master
to
szokeasaurusrex/non-exhaustive-client-options
July 8, 2026 13:57
szokeasaurusrex
requested review from
Litarnus and
giortzisg
and removed request for
alexander-alderman-webb
July 20, 2026 15:07
szokeasaurusrex
force-pushed
the
szokeasaurusrex/traces-sampling-strat
branch
2 times, most recently
from
July 20, 2026 16:23
5b4847f to
522505d
Compare
szokeasaurusrex
changed the base branch from
szokeasaurusrex/non-exhaustive-client-options
to
szokeasaurusrex/default-metrics-and-logs
July 20, 2026 16:23
Represent traces sampling as a single strategy enum so that leaving tracing unset is different from explicitly configuring a fixed sample rate of `0.0`. This keeps sampler callbacks, fixed rates, and disabled tracing mutually exclusive instead of modeling impossible combinations. This does not fully implement deferred trace propagation semantics yet. It makes the public API capable of representing the distinction the propagation spec needs, so a future implementation can treat unset tracing config differently from an explicit zero sample rate without another public API change. Update transaction sampling tests and the changelog for the enum-based behavior, including that disabled tracing never samples even when the transaction context carries an explicit sampling decision. BREAKING CHANGE: `ClientOptions::traces_sample_rate` and `ClientOptions::traces_sampler` fields are replaced by `ClientOptions::traces_sampling_strategy`.
szokeasaurusrex
force-pushed
the
szokeasaurusrex/traces-sampling-strat
branch
from
July 20, 2026 16:29
522505d to
c775cb9
Compare
Litarnus
approved these changes
Jul 21, 2026
giortzisg
approved these changes
Jul 21, 2026
szokeasaurusrex
added a commit
that referenced
this pull request
Jul 21, 2026
Replace the public `ClientOptions::sample_rate` field with an `EventSamplingStrategy` enum while preserving the existing `sample_rate(...)` builder API for fixed-rate event sampling. This mirrors the traces sampling model added in #1227 and unblocks #1127 by making it possible to add a sampling function variant to `EventSamplingStrategy` without another public field replacement. BREAKING CHANGE: Remove the public `ClientOptions::sample_rate` field. Use `ClientOptions::event_sampling_strategy` to inspect event sampling configuration, and continue using `ClientOptions::sample_rate(...)` to configure a fixed sample rate. References [#1127](<https://github.com/getsentry/sentry-rust/issues/1127>)<br>References #1127
This was referenced Jul 28, 2026
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 11, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change alters the internal representations of spans and transactions so the `sampled` flag is an `Option<bool>` rather than a `bool`, allowing us to represent the disabled-tracing state as `None` rather than `false` (unsampled transactions/spans now instead have `Some(false)`). For the most part, these changes do not yet alter externally-observable SDK behavior; we continue to treat the disabled tracing case as a sample rate of 0.0. The main place where this PR may affect behavior is in `TransactionContext::continue_from_span` when the SDK has multiple clients: if a transaction on a client which has tracing enabled is continued from a transaction on a tracing-disabled client, the transaction will be sampled according to its client's configured sample rate. Previously, the transaction would not have been sampled, as we would have treated the incoming trace as unsampled rather than having a deferred sampling decision. Follow up PRs will implement the correct outgoing trace-header propagation (i.e. correctly propagating traces that should have a deferred sampling decision) and removing `sample_rate` client reports when tracing is disabled. Unblocks [#1282](#1282) Unblocks [RUST-272](https://linear.app/getsentry/issue/RUST-272) Unblocks [#1289](#1289) Unblocks [RUST-273](https://linear.app/getsentry/issue/RUST-273)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 12, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change fundemantally alters the semantics around how disabled tracing is handled. Spans/Transactions now keep track of a so-called `TracingState` which keeps track of both whether tracing is enabled and what the sampling decision is. When tracing is enabled, there will always be a sampling decision (including a corresponding sample rate); when tracing is disabled, a sampling decision may be available if the trace was continued from an incoming trace with a sampling decision. Traces started in the SDK when tracing is disabled never have a sampling decision. We then separate the concepts of sampling decision and whether to capture traces. The sampling decision now can correctly represent the case where the decision has been deferred. Span/Transaction tracing headers will always include this sampling decision, regardless of whetehr the SDK is capturing the corresponding the Span/Transaction. For whether to capture traces, we now use a `FinishAction` with three possibilities: `Send` and `Discard` are both used when tracing is enabled and are used for sampled and unsampled traces, respectively, while `Ignore` is used for all traces when tracing is disabled. Both `Discard` and `Ignore` result in spans/transactions not being sent to Sentry, but only `Discard` sends a client report. Resolves [#1289](#1289) Resolves [RUST-273](https://linear.app/getsentry/issue/RUST-273) Resolves [#1282](#1282) Resolves [RUST-272](https://linear.app/getsentry/issue/RUST-272)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 12, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change alters the semantics for disabled tracing in several ways: - Spans and Transactions now represent their sampled flags as `Option<bool>`, so that they can distinguish between unsampled versus tracing disabled/sampling decision deferred - If a Transaction is continued from a disabled-tracing Span, it correctly treats the incoming Span as having a deferred sampling decision rather than assuming that the incoming span was unsampled and inheriting the decision. This is somewhat of an edge case; it would primarily produce an observable difference in a two-Client setup where a Span created on a Client with disabled tracing is continued as a Transaction on a Client which has tracing enabled. - The outgoing trace headers on a disabled Transaction or Span now correctly omit the sampling decision flag, rather than including `-0` in the `sentry-trace` header. Resolves [#1289](#1289) Resolves [RUST-273](https://linear.app/getsentry/issue/RUST-273) Unblocks [#1282](#1282) Unblocks [RUST-272](https://linear.app/getsentry/issue/RUST-272)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 12, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change fundemantally alters the semantics around how disabled tracing is handled. Spans/Transactions now keep track of a so-called `TracingState` which keeps track of both whether tracing is enabled and what the sampling decision is. When tracing is enabled, there will always be a sampling decision (including a corresponding sample rate); when tracing is disabled, a sampling decision may be available if the trace was continued from an incoming trace with a sampling decision. Traces started in the SDK when tracing is disabled never have a sampling decision. We then separate the concepts of sampling decision and whether to capture traces. The sampling decision now can correctly represent the case where the decision has been deferred. Span/Transaction tracing headers will always include this sampling decision, regardless of whetehr the SDK is capturing the corresponding the Span/Transaction. For whether to capture traces, we now use a `FinishAction` with three possibilities: `Send` and `Discard` are both used when tracing is enabled and are used for sampled and unsampled traces, respectively, while `Ignore` is used for all traces when tracing is disabled. Both `Discard` and `Ignore` result in spans/transactions not being sent to Sentry, but only `Discard` sends a client report. Resolves [#1289](#1289) Resolves [RUST-273](https://linear.app/getsentry/issue/RUST-273) Resolves [#1282](#1282) Resolves [RUST-272](https://linear.app/getsentry/issue/RUST-272)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 26, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change fundemantally alters the semantics around how disabled tracing is handled. Spans/Transactions now keep track of a so-called `TracingState` which keeps track of both whether tracing is enabled and what the sampling decision is. When tracing is enabled, there will always be a sampling decision (including a corresponding sample rate); when tracing is disabled, a sampling decision may be available if the trace was continued from an incoming trace with a sampling decision. Traces started in the SDK when tracing is disabled never have a sampling decision. We then separate the concepts of sampling decision and whether to capture traces. The sampling decision now can correctly represent the case where the decision has been deferred. Span/Transaction tracing headers will always include this sampling decision, regardless of whetehr the SDK is capturing the corresponding the Span/Transaction. For whether to capture traces, we now use a `FinishAction` with three possibilities: `Send` and `Discard` are both used when tracing is enabled and are used for sampled and unsampled traces, respectively, while `Ignore` is used for all traces when tracing is disabled. Both `Discard` and `Ignore` result in spans/transactions not being sent to Sentry, but only `Discard` sends a client report. Resolves [#1289](#1289) Resolves [RUST-273](https://linear.app/getsentry/issue/RUST-273) Resolves [#1282](#1282) Resolves [RUST-272](https://linear.app/getsentry/issue/RUST-272)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 31, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change fundemantally alters the semantics around how disabled tracing is handled. Spans/Transactions now keep track of a so-called `TracingState` which keeps track of both whether tracing is enabled and what the sampling decision is. When tracing is enabled, there will always be a sampling decision (including a corresponding sample rate); when tracing is disabled, a sampling decision may be available if the trace was continued from an incoming trace with a sampling decision. Traces started in the SDK when tracing is disabled never have a sampling decision. We then separate the concepts of sampling decision and whether to capture traces. The sampling decision now can correctly represent the case where the decision has been deferred. Span/Transaction tracing headers will always include this sampling decision, regardless of whetehr the SDK is capturing the corresponding the Span/Transaction. For whether to capture traces, we now use a `FinishAction` with three possibilities: `Send` and `Discard` are both used when tracing is enabled and are used for sampled and unsampled traces, respectively, while `Ignore` is used for all traces when tracing is disabled. Both `Discard` and `Ignore` result in spans/transactions not being sent to Sentry, but only `Discard` sends a client report. Resolves [#1289](#1289) Resolves [RUST-273](https://linear.app/getsentry/issue/RUST-273) Resolves [#1282](#1282) Resolves [RUST-272](https://linear.app/getsentry/issue/RUST-272)
szokeasaurusrex
added a commit
that referenced
this pull request
Aug 31, 2026
PR #1227 enabled us to represent disabled tracing differently from a 0.0 sample rate when the SDK is initialized but left the behavior for the two cases largely the same. This change fundamentally alters the semantics around how disabled tracing is handled. Spans/Transactions now keep track of a so-called `TracingState` which keeps track of both whether tracing is enabled and what the sampling decision is. When tracing is enabled, there will always be a sampling decision (including a corresponding sample rate); when tracing is disabled, a sampling decision may be available if the trace was continued from an incoming trace with a sampling decision. Traces started in the SDK when tracing is disabled never have a sampling decision. We then separate the concepts of sampling decision and whether to capture traces. The sampling decision now can correctly represent the case where the decision has been deferred. Span/Transaction tracing headers will always include this sampling decision, regardless of whetehr the SDK is capturing the corresponding the Span/Transaction. For whether to capture traces, we now use a `FinishAction` with three possibilities: `Send` and `Discard` are both used when tracing is enabled and are used for sampled and unsampled traces, respectively, while `Ignore` is used for all traces when tracing is disabled. Both `Discard` and `Ignore` result in spans/transactions not being sent to Sentry, but only `Discard` sends a client report.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Represent traces sampling as a single strategy enum so that leaving tracing unset is different from explicitly configuring a fixed sample rate of
0.0. This keeps sampler callbacks, fixed rates, and disabled tracing mutually exclusive instead of modeling impossible combinations.This does not fully implement deferred trace propagation semantics yet. It makes the public API capable of representing the distinction the propagation spec needs, so a future implementation can treat unset tracing config differently from an explicit zero sample rate without another public API change.
Update transaction sampling tests to cover the enum-based behavior, including that disabled tracing never samples even when the transaction context carries an explicit sampling decision.
BREAKING CHANGE:
ClientOptions::traces_sample_rateandClientOptions::traces_samplerfields are replaced byClientOptions::traces_sampling_strategy.