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

chore: fixing problem with load event and performance for loadend #469

Merged
merged 6 commits into from
Nov 2, 2019

Conversation

obecny
Copy link
Member

@obecny obecny commented Oct 30, 2019

Which problem is this PR solving?

It appeared that load event might not yet have the performance metrics for loadEnd The support for loadEnd 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.

@codecov-io
Copy link

codecov-io commented Oct 30, 2019

Codecov Report

Merging #469 into master will increase coverage by 0.17%.
The diff coverage is 100%.

@@            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
Impacted Files Coverage Δ
...telemetry-plugin-document-load/src/documentLoad.ts 97.75% <100%> (+0.07%) ⬆️
...entelemetry-plugin-postgres/test/assertionUtils.ts 96.55% <0%> (-3.45%) ⬇️
...opentelemetry-base/test/resources/resource.test.ts 100% <0%> (ø) ⬆️
...entelemetry-exporter-jaeger/test/transform.test.ts 100% <0%> (ø) ⬆️
...ges/opentelemetry-exporter-zipkin/src/transform.ts 100% <0%> (ø) ⬆️
.../opentelemetry-exporter-zipkin/test/zipkin.test.ts 100% <0%> (ø) ⬆️
.../opentelemetry-exporter-jaeger/test/jaeger.test.ts 100% <0%> (ø) ⬆️
...telemetry-scope-base/test/NoopScopeManager.test.ts 100% <0%> (ø) ⬆️
packages/opentelemetry-web/src/WebTracer.ts 100% <0%> (ø) ⬆️
...entelemetry-exporter-zipkin/test/transform.test.ts 100% <0%> (ø) ⬆️
... and 3 more

// Support for event "loadend" is very limited and cannot be used
window.setTimeout(() => {
this._collectPerformance();
});
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

@mayurkale22 mayurkale22 added this to the Alpha v0.2 milestone Nov 1, 2019
@mayurkale22 mayurkale22 added the enhancement New feature or request label Nov 1, 2019
@mayurkale22 mayurkale22 merged commit d5141f7 into open-telemetry:master Nov 2, 2019
@obecny obecny deleted the document-load-fix branch July 8, 2020 12:11
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants