fix(fetch): end span after body is received#2203
Merged
vmarchaud merged 4 commits intoopen-telemetry:mainfrom May 19, 2021
Merged
fix(fetch): end span after body is received#2203vmarchaud merged 4 commits intoopen-telemetry:mainfrom
vmarchaud merged 4 commits intoopen-telemetry:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2203 +/- ##
==========================================
- Coverage 92.72% 92.71% -0.02%
==========================================
Files 141 141
Lines 5089 5106 +17
Branches 1047 1049 +2
==========================================
+ Hits 4719 4734 +15
- Misses 370 372 +2
|
obecny
approved these changes
May 13, 2021
Member
obecny
left a comment
There was a problem hiding this comment.
this is really nice finding, thx for fixes, lgtm, just some name change suggestions
Contributor
Author
|
@dyladan @vmarchaud Can I get one more review and if possible get it merged soon? Would really like to have this before next release. |
vmarchaud
approved these changes
May 19, 2021
dyladan
approved these changes
May 19, 2021
8 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.
Which problem is this PR solving?
Currently fetch span end is called when
fetch().thenfires and 300ms wait time(for resource timings) is over. But fetch() promise resolves as soon as the server responds with headers so if getting the body takes more than 300ms there will never be any resource timings for this span and span end time will be incorrect also. To reproduce it just make a fetch and set connection speed slow in dev tools and you can see that none of the fetches have resource timings.Short description of the changes
I clone the response and read the response body until it is done and end the span then. Not a pretty solution but this covers all of the cases I know about. Another potential way to fix this would be to wrap all body methods (.json .blob etc.) but that still leaves some use cases uncovered. Some changes to tests so done isn't called too early (took a looong time to get them stable). Also fixed some TS warnings in tests. Probably could get rid of the 300ms timeout now but I am not yet bold enough.