-
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-407] improve resource timings collection #315
[RUMF-407] improve resource timings collection #315
Conversation
6b52e44
to
5a0ddca
Compare
test/e2e/scenario/agents.scenario.ts
Outdated
const timing = await makeXHRAndCollectEvent(`${browser.config.baseUrl}/ok`) | ||
expect(timing).not.toBeUndefined() | ||
expect(timing!.http.method).toEqual('GET') | ||
expect((timing!.http as any).status_code).toEqual(200) | ||
expectToHaveValidTimings(timing!) |
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.
const timing = await makeXHRAndCollectEvent(`${browser.config.baseUrl}/ok`) | |
expect(timing).not.toBeUndefined() | |
expect(timing!.http.method).toEqual('GET') | |
expect((timing!.http as any).status_code).toEqual(200) | |
expectToHaveValidTimings(timing!) | |
const timing = await makeXHRAndCollectEvent(`${browser.config.baseUrl}/ok`)! | |
expect(timing).not.toBeUndefined() | |
expect(timing.http.method).toEqual('GET') | |
expect((timing.http as any).status_code).toEqual(200) | |
expectToHaveValidTimings(timing) |
and for other occurences
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.
Ok. In TS 3.8, I'd like to make something like:
function expectDefined<T>(value: T | undefined): asserts value is T {
expect(value).toBeDefined()
}
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.
Does it worth the trouble?
IMO, it does not bring much more than the !
operator and we (or at least I 😄) could forget the existence of this helper easily since it is pretty specific.
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.
We'll see if it can improve the situation. This is great to link the TS type to the actual JS type at runtime :) !
should be avoided if possible, in the same way as as
casts.
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.
ok, let's try
Codecov Report
@@ Coverage Diff @@
## master #315 +/- ##
==========================================
+ Coverage 85.56% 85.65% +0.09%
==========================================
Files 25 25
Lines 1413 1429 +16
Branches 309 302 -7
==========================================
+ Hits 1209 1224 +15
- Misses 204 205 +1
Continue to review full report at Codecov.
|
With this PR, we try to improve the resources timing collection in different ways:
Better cross browser support:
timing.duration
isn't available or 0, useresponseEnd - startTime
instead, if available (Safari)redirectStart
isn't available, usestartTime
instead (Firefox)redirectEnd
isn't available, usefetchStart
instead (Firefox)Change how the timings
start
are computed: use difference (in nanosecond) between the requeststartTime
and the timing start, so we can build reliable timings diagram.startTime
instead of 0 since it should not happen and would provide negative timingsstart
.Report timings for all cached resources, as we've seen that we can't accurately know if a resource is cached or not (timings may not be 0 when cached)