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

Attention: Patch coverage is 95.15419% with 11 lines in your changes missing coverage. Please review.

Project coverage is 87.50%. Comparing base (f172792) to head (6bec26c).

Files with missing lines Patch % Lines
packages/rum/src/rum.ts 70.58% 5 Missing ⚠️
packages/rum/src/rum.entry.ts 90.90% 4 Missing ⚠️
packages/core/src/fetchProxy.ts 97.72% 1 Missing ⚠️
packages/rum/src/requestCollection.ts 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@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.

3 participants