-
Notifications
You must be signed in to change notification settings - Fork 806
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
chore: fixing problem with load event and performance for loadend #469
Conversation
Codecov Report
@@ Coverage Diff @@
## master #469 +/- ##
==========================================
+ Coverage 95.19% 95.37% +0.17%
==========================================
Files 137 137
Lines 6833 7003 +170
Branches 594 598 +4
==========================================
+ Hits 6505 6679 +174
+ Misses 328 324 -4
|
packages/opentelemetry-plugin-document-load/src/documentLoad.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-plugin-document-load/src/documentLoad.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-plugin-document-load/test/documentLoad.test.ts
Outdated
Show resolved
Hide resolved
// Support for event "loadend" is very limited and cannot be used | ||
window.setTimeout(() => { | ||
this._collectPerformance(); | ||
}); |
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.
Would it make sense to have a little delay here, e.g. 1 second or so?
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.
if I understand correctly it should work like this. When load event is being called then the performance is collecting the remaining metrics included "loadEnd", I assume this is synchronous so whenever this is finished the browser will start executing all the timeouts that were set together with the same load event. Then it really doesn't make sense to wait longer as the loadEnd
metric should be there. If this is not the case then it will be hard to really say how long you should wait, 100ms, 1s, maybe 2s, but it seems like the moment the setTimeout calls the callback this metric is already there.
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.
In the end this is not final, we can always put there 1s at any moment if for any reason it appeared that some browsers don't have it yet.
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Which problem is this PR solving?
It appeared that
load
event might not yet have the performance metrics forloadEnd
The support forloadEnd
event is very limited and cannot be used instead. The solution is to use timeout when document loads so that this one missing performance metric is in place.