Repository navigation
🐛 Avoid duplicate tracing for marked fetch polyfills - #5147
Draft
adityareddy-dev wants to merge 1 commit into
Draft
adityareddy-dev wants to merge 1 commit into
adityareddy-dev wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This branch has not been deployed
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.
Motivation
Addresses the marked global polyfill case in #2940. Observing both fetch and its underlying XHR produces duplicate request observations and appends two sets of tracing headers to one request.
Changes
Use the existing XHR observer for globally installed XHR-backed fetch polyfills with
fetch.polyfill === true, such as whatwg-fetch. Native and unmarked fetch functions keep their current behavior. Marked polyfills without an XMLHttpRequest property are still observed through fetch.These calls use XHR context, so fetch input, init and response context and fetch-only request-header capture are unavailable. Logs handles failures through its XHR path. Global wrappers that drop the marker remain outside this fix.
Test instructions
Run
yarn test:unit --spec packages/browser-core/src/browser/fetchObservable.spec.ts --spec packages/browser-core/src/browser/xhrObservable.spec.ts --spec packages/browser-rum-core/src/domain/requestCollection.spec.ts --spec packages/browser-rum-core/src/domain/tracing/tracer.spec.ts,yarn test:unit --spec packages/browser-logs/src/domain/networkError/networkErrorCollection.spec.tsandyarn typecheck.The regression drives an XHR-backed fetch test double through buffering, request collection and the real tracer. Before the change it produces two started and completed requests and eight tracing-header writes. With the change it produces one completed XHR request and four header writes whose trace and span IDs match that request. The four-header assertion uses only the Datadog propagator, with baggage disabled. These assertions cover request lifecycle events, actual whatwg-fetch integration and staging validation remain unverified.
The four-spec command passes 107 tests and the Logs command passes 13 tests. Typecheck, ESLint and formatting pass for the changed files.
Checklist