-
Notifications
You must be signed in to change notification settings - Fork 142
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-876] Improve proxy behavior for xhr reuse #865
Conversation
fe3b5d6
to
461397e
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #865 +/- ##
==========================================
- Coverage 89.13% 88.84% -0.30%
==========================================
Files 81 81
Lines 3791 3764 -27
Branches 848 834 -14
==========================================
- Hits 3379 3344 -35
- Misses 412 420 +8 ☔ View full report in Codecov by Sentry. |
461397e
to
fd3c9dc
Compare
7c221fe
to
d3da97f
Compare
d3da97f
to
9903554
Compare
d3002b6
to
f0d1d2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return originalXhrAbort.apply(this, arguments as any) | ||
} | ||
|
||
function reportXhr(xhr: BrowserXHR<XhrStartContext>, pendingContext: XhrStartContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the reasoning for not retrieving the context from xhr anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can simplify
function reportXhr(xhr: BrowserXHR<XhrStartContext>, pendingContext: XhrStartContext) { | ||
const xhrCompleteContext: XhrCompleteContext = { | ||
...pendingContext, | ||
duration: elapsed(pendingContext.startClocks.timeStamp, timeStampNow()), | ||
response: xhr.response as string | undefined, | ||
status: xhr.status, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about reinforcing the design by having something like:
function reportXhr(xhr: BrowserXHR<XhrStartContext>, pendingContext: XhrStartContext) { | |
const xhrCompleteContext: XhrCompleteContext = { | |
...pendingContext, | |
duration: elapsed(pendingContext.startClocks.timeStamp, timeStampNow()), | |
response: xhr.response as string | undefined, | |
status: xhr.status, | |
} | |
function reportXhr(xhr: BrowserXHR<XhrCompleteContext>) { | |
xhr._datadog_xhr!.duration = elapsed(pendingContext.startClocks.timeStamp, timeStampNow()) | |
... | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
On thing I see, by doing this, is that I have to cast like so reportXhr(this as BrowserXHR<XhrCompleteContext>)
in sendXhr()
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems good enough to me
Detected issues
max stack size error
when using a single instance ofXMLHTTPRequest
.Changes
Testing
Unit, Locally
I have gone over the contributing documentation.