Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(instrumentation-fetch): removes CORS sub-span creation as it was … #5130

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mariomc
Copy link

@mariomc mariomc commented Nov 8, 2024

Which problem is this PR solving?

Fixes #5122

In instrumentation-fetch and instrumentation-xhr, we're including logic to find preflight requests and create (nested) spans for them.
However, that is unnecessary complexity as OPTIONS/preflight calls for a cross-domain request are not added as an additional entry in the PerformanceEntry list and, much like redirects and other preconditions, are accounted for in the main resource entry (despite not being able to differentiate between one and the other).

A simple test can be done by executing the following:

(async () => {
  const CORS_URL = "https://httpbin.org/headers";
  await fetch(CORS_URL).then((a) => a.json());
  const entries = performance.getEntriesByName(CORS_URL);
  console.log("Number of entries:", entries.length);
})();

Short description of the changes

Removed CORS child span creation, filtering and other logic.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Tested the demo for both instrumentation-fetch and instrumentation-xhr in: Google Chrome 130, Safari 18, Firefox 131. Noticed there were no child spans being created for OPTIONS/preflight requests nor performance entries being added for CORS-enabled requests.
  • Tested a simple html app doing a cross-domain fetch request and consulted the performance entries.

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Nov 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

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.

CORS Preflight Requests not accounted for
1 participant