Open mariomc opened 2 weeks ago
It's not really clear what you mean here. In the issue you say "CORS preflight requests are created as child spans of the main request" but in the PR you introduced it looks like you're actually removing this behavior? Are you saying the behavior doesn't work and should be removed for that reason? Or are you saying we shouldn't be creating these spans at all?
Are you saying the behavior doesn't work and should be removed for that reason?
Thank you for the reply. Exactly.
The current code was built upon what seems a false assumption: that there's two Performance entries per each cross-origin request (one for the preflight/OPTIONS/CORS, another for the actual request). There isn't. (Maybe this was the case in some early implementations of the Resource Timing spec?)
At least as per Resource Timing level 2, request preconditions (authentication, redirects, CORS) are accounted for as a part of the entry of the originator request. There is no way of, with the PerformanceResourceTiming, extracting (or inferring) data for the CORS preflight request specifically. Which means that we could drop this code entirely: needing to find the duplicate (there will never be one) and if there's one, using it to create a nested span.
What happened?
Currently XHR and Fetch instrumentation are treating CORS with the assumption that there's 2 entries (one for the actual request, another for the preflight) on the performance entry. This is not the case.
Steps to Reproduce
web-opentelemetry-example
Expected Result
Actual Result
Additional Details
I believe this behaviour happens because according to Resource Timing Level 2:
Which means there's no duplicate entry performance entry in case of preflights.
OpenTelemetry Setup Code
package.json
Relevant log output
No response