-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(tracing-internal): Only collect request/response spans when browser performance timing is available #10207
Conversation
…er performance timing is available
size-limit report 📦
|
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.
I'm not sure I understand why Relay drops an entire transaction because of a "bad" span but guarding for this makes sense IMO.
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.
Can we add a test so we don't regress in the future?
// It is possible that we are collecting these metrics when the page hasn't finished loading yet, for example when the HTML slowly streams in. | ||
// In this case, ie. when the document request hasn't finished yet, `entry.responseEnd` will be 0. | ||
// In order not to produce faulty spans, where the end timestamp is before the start timestamp, we will only collect | ||
// these spans when the responseEnd value is available. Relay would drop the entire transaction if it contained faulty spans. |
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.
// these spans when the responseEnd value is available. Relay would drop the entire transaction if it contained faulty spans. | |
// these spans when the responseEnd value is available. The backend would drop the entire transaction if it contained faulty spans. |
Maybe a bit more generic, for outside readers :)
// In this case, ie. when the document request hasn't finished yet, `entry.responseEnd` will be 0. | ||
// In order not to produce faulty spans, where the end timestamp is before the start timestamp, we will only collect | ||
// these spans when the responseEnd value is available. Relay would drop the entire transaction if it contained faulty spans. | ||
if (entry.responseEnd !== 0) { |
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 (entry.responseEnd !== 0) { | |
if (entry.responseEnd) { |
save a few bytes and should be equally correct here?
I found that Relay was dropping pageload transactions from my Next.js test app pretty consistently so in my debugging journey I discovered that the reason was that we were sending spans with start timestamps larger than the end timestamps.
Root cause was that we assumed that the
responseEnd
property on thenavigation
performance entry is always present. It is, however, when the response hasn't finished yet, it is0
.As a fallback behaviour, this PR changes the logic so we will only collect these performance entry spans when the
responseEnd
logic is available.We should probably delay finishing of the pageload transaction until domContentLoded fired or the timeout is reached...