[V2] [FIX] Update resourceTracingSamplingRate on deferred DatadogProvider initialization#1290
Merged
sbarrio merged 1 commit intoMay 26, 2026
Conversation
659f211 to
edef4c6
Compare
There was a problem hiding this comment.
Pull request overview
Fixes deferred initialization (via DatadogProvider + later DatadogProvider.initialize) so that resourceTracingSamplingRate/first-party-host tracing settings are applied to the already-installed JS XHR instrumentation, preventing Android from being stuck at the default sampling rate.
Changes:
- Added a tracking-context update mechanism (
onTrackingUpdate) to the request proxy abstraction and implemented it inXHRProxyby reading sampling/hosts from a mutable context atopen()time. - Introduced
DdRumResourceTracking.updateTrackingContext()and invoked it during deferred initialization to re-apply resolved tracing values. - Extended partial initialization config to accept
resourceTracingSamplingRateand added regression tests for XHR sampling rate updates.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.ts | Makes XHR tracing attributes read from a mutable context and adds onTrackingUpdate. |
| packages/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/tests/XHRProxy.test.ts | Adds regression tests validating that updated sampling rate affects subsequent XHRs. |
| packages/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.ts | Extends the request proxy contract with onTrackingUpdate. |
| packages/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.tsx | Adds updateTrackingContext wrapper to update an installed proxy. |
| packages/core/src/DdSdkReactNativeConfiguration.tsx | Allows resourceTracingSamplingRate in PartialInitializationConfiguration. |
| packages/core/src/DdSdkReactNative.tsx | Calls updateTrackingContext during deferred initialization before native init. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edef4c6 to
2506136
Compare
4 tasks
4 tasks
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?
When using delayedinitialization via the DatadogProvider (giving a basic initialization to the provider and later calling DatadogProvider.Initialize with the full config), if the user was to set
resourceTracingSamplingRateviaDatadogProvider.initialize(...)this value would end up being ignored by the JS XHRProxy. This was pretty apparent on Android, as the tracing would be stuck at the default 20%. on iOS however this resourceTracingSampligRate would be actually used (nativeInitialization is still called in this path), so the bug was masked.Motivation
Setting the resourceTracingSamplingRate when using deferred initialization should work.
Additional Notes
Before fix (setting resourceTracingSampligRate on`DatadogProvider.initialize(...)
(Note the sampligPriority being 0)
After fix
Review checklist (to be filled by reviewers)