RUM-15138: Preserve custom DeterministicTraceSampler subclasses from rebasing#3455
Merged
hamorillo merged 1 commit intoMay 19, 2026
Merged
Conversation
…rebasing Tighten the SessionRebasedSampler wrap condition in DatadogInterceptor.Builder and ApmNetworkInstrumentationConfiguration.createInstrumentation from `is DeterministicTraceSampler` to an exact-class check, so subclasses passed via setTraceSampler are preserved as-is and bypass cross-product rebasing. This matches the documented setTraceSampler contract that custom samplers should not be rebased. Updated KDoc on setTraceSampler in TracingInterceptor and ApmNetworkInstrumentationConfiguration to clarify that subclasses of DeterministicTraceSampler are also treated as custom samplers and that only an exact DeterministicTraceSampler instance (equivalent to setTraceSampleRate) participates in rebasing. Added test coverage in DatadogInterceptorBuilderTest and ApmInstrumentationConfigurationTest asserting subclass instances are not wrapped.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3455 +/- ##
===========================================
- Coverage 72.22% 72.17% -0.05%
===========================================
Files 964 964
Lines 35497 35500 +3
Branches 5896 5897 +1
===========================================
- Hits 25635 25620 -15
- Misses 8258 8263 +5
- Partials 1604 1617 +13
🚀 New features to boost your workflow:
|
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
hamorillo
marked this pull request as ready for review
May 19, 2026 09:01
0xnm
approved these changes
May 19, 2026
kikoveiga
approved these changes
May 19, 2026
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.
What does this PR do?
Replaces the
is DeterministicTraceSamplertype check at two call sites (DatadogInterceptor.Builder.build()andApmNetworkInstrumentationConfiguration.createInstrumentation) with an exact-class match, so subclasses ofDeterministicTraceSamplerpassed viasetTraceSampler()are preserved as custom samplers and bypass cross-product rebasing. KDoc onsetTraceSamplerinTracingInterceptorandApmNetworkInstrumentationConfigurationupdated to clarify this behavior.Motivation
Codex flagged a P2 in PR #3454: when a customer passes a
DeterministicTraceSamplersubclass viasetTraceSampler(), the previousis DeterministicTraceSamplercheck still wrapped it inSessionRebasedSampler. InsideSessionRebasedSampler.sample(), when the combined rate differs from the raw rate, a freshDeterministicTraceSampler(effectiveRate)is constructed and used — silently bypassing the customer's subclass logic. This contradicts the documentedsetTraceSamplercontract that custom samplers do not participate in cross-product rebasing.With the exact-class match, only an exact
DeterministicTraceSamplerinstance (which is whatsetTraceSampleRateproduces internally) is wrapped. Subclasses and any other customSampler<DatadogSpan>are preserved as-is.Review checklist (to be filled by reviewers)