-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(react): Use new span API in React Profiler #10104
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
Conversation
@@ -1,8 +1,5 @@ | |||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ |
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.
nice! ❤️ less lint exceptions...
packages/react/src/profiler.tsx
Outdated
description: `<${name}>`, | ||
const activeSpan = getActiveSpan(); | ||
if (activeSpan) { | ||
this._mountSpan = startInactiveSpan({ |
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.
just thinking, do we need to check here if _mountSpan
(same below for _updateSpan
) is already set, to ensure we clean up the span? 🤔 or are we fine just overwriting the reference?
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.
Yup we should do a check - 934da39
packages/react/src/profiler.tsx
Outdated
name: `<${this.props.name}>`, | ||
op: REACT_UPDATE_OP, | ||
origin: 'auto.ui.react.profiler', | ||
startTimestamp: now, | ||
data: { |
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.
l: while we at it, we should also rename this to attributes
everywhere! We can also do this in a follow up, though.
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.
Done with c517e92, will keep it in mind for the future.
packages/react/src/profiler.tsx
Outdated
op: REACT_UPDATE_OP, | ||
origin: 'auto.ui.react.profiler', | ||
startTimestamp: now, | ||
parentSpanId: this._mountSpan.spanContext().spanId, |
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.
this will not work anymore going forward - parentSpanId
is/will be deprecated. Instead, you need to pass a scope
that has the correct span as active span! 😬 But you can basically do this:
const scope = new Scope();
scope.setSpan(this._mountSpan);
startInactiveSpan({ scope, ... });
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.
dang, good to know. Fixed with 64a14b6
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.
Ahh scope.setSpan
is deprecated 😢
Any other way we can enforce the parent child relationship here?
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.
The way to go is #10195, which Luca just added for exactly this case :D
fa10cf6
to
ef7a534
Compare
size-limit report 📦
|
ref #10100