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

[RUMF-617] Extract XHR and Fetch proxies #468

Merged
merged 12 commits into from
Aug 5, 2020

Conversation

bcaudan
Copy link
Contributor

@bcaudan bcaudan commented Jul 29, 2020

Motivation

Current proxies of XHR and fetch were managed by request collection which was handled as a singleton to avoid to proxy XHR and fetch multiple times.
With the future integration of tracing inside the sdk (cf #461), we would want to collect request with trace id for rum but not for logs.
In a npm setup this would be problematic since the request collection instance would be shared between rum and logs.

Changes

  1. Extract XHR and Fetch proxies that:
    • instrument browser API only once
    • deal with request data, not with domain logic (request id, trace id, request type)
    • provide hooks to attach/retrieve info during the request life cycle
  2. Use proxies in request collection and error collection
  3. Move request collection to rum package

Testing

Automated tests


I have gone over the contributing documentation.

update the design to ease the testing
not mandatory but I lost some time suspecting an issue with that...
@bcaudan bcaudan force-pushed the bcaudan/extract-singleton-for-proxy branch 2 times, most recently from c454de2 to 59061d3 Compare July 29, 2020 13:42
@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2020

Codecov Report

Merging #468 into master will increase coverage by 0.08%.
The diff coverage is 95.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #468      +/-   ##
==========================================
+ Coverage   87.41%   87.50%   +0.08%     
==========================================
  Files          32       34       +2     
  Lines        2034     2112      +78     
  Branches      411      416       +5     
==========================================
+ Hits         1778     1848      +70     
- Misses        256      264       +8     
Impacted Files Coverage Δ
packages/rum/src/lifeCycle.ts 100.00% <ø> (ø)
packages/rum/src/matchRequestTiming.ts 93.75% <ø> (ø)
packages/rum/src/rum.ts 86.15% <70.58%> (-0.63%) ⬇️
packages/rum/src/rum.entry.ts 73.21% <90.90%> (+1.51%) ⬆️
packages/rum/src/requestCollection.ts 96.87% <96.87%> (ø)
packages/core/src/fetchProxy.ts 97.72% <97.72%> (ø)
packages/core/src/errorCollection.ts 98.82% <100.00%> (+0.13%) ⬆️
packages/core/src/utils.ts 86.98% <100.00%> (-2.78%) ⬇️
packages/core/src/xhrProxy.ts 100.00% <100.00%> (ø)
packages/logs/src/logs.entry.ts 52.38% <100.00%> (+2.38%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f172792...6bec26c. Read the comment docs.

@bcaudan bcaudan force-pushed the bcaudan/extract-singleton-for-proxy branch from 59061d3 to 76017bd Compare July 29, 2020 13:44
@bcaudan bcaudan changed the title [RUMF-617] Extract XHR and Fetch proxy [RUMF-617] Extract XHR and Fetch proxies Jul 29, 2020
@bcaudan bcaudan force-pushed the bcaudan/extract-singleton-for-proxy branch from 76017bd to c311c29 Compare July 29, 2020 13:47
prevent batch from previous tests to keep running and send unwanted requests
@bcaudan bcaudan marked this pull request as ready for review July 29, 2020 16:00
@bcaudan bcaudan requested a review from a team as a code owner July 29, 2020 16:00
packages/core/src/fetchProxy.ts Show resolved Hide resolved
packages/core/src/xhrProxy.ts Show resolved Hide resolved
packages/logs/test/logs.entry.spec.ts Outdated Show resolved Hide resolved
packages/core/test/requestCollection.spec.ts Outdated Show resolved Hide resolved
packages/rum/src/rum.ts Show resolved Hide resolved
packages/core/src/fetchProxy.ts Show resolved Hide resolved
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bcaudan bcaudan merged commit f8d4820 into master Aug 5, 2020
@bcaudan bcaudan deleted the bcaudan/extract-singleton-for-proxy branch August 5, 2020 13:43
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.

None yet

3 participants