Skip to content

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

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

AbhiPrasad
Copy link
Member

ref #10100

@AbhiPrasad AbhiPrasad requested review from a team, anonrig and ale-cota and removed request for a team January 8, 2024 16:16
@AbhiPrasad AbhiPrasad changed the title ref: Use new span API in React Profiler ref(react): Use new span API in React Profiler Jan 8, 2024
@AbhiPrasad AbhiPrasad requested a review from mydea January 8, 2024 17:21
@AbhiPrasad AbhiPrasad self-assigned this Jan 8, 2024
@@ -1,8 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! ❤️ less lint exceptions...

description: `<${name}>`,
const activeSpan = getActiveSpan();
if (activeSpan) {
this._mountSpan = startInactiveSpan({
Copy link
Member

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?

Copy link
Member Author

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

name: `<${this.props.name}>`,
op: REACT_UPDATE_OP,
origin: 'auto.ui.react.profiler',
startTimestamp: now,
data: {
Copy link
Member

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.

Copy link
Member Author

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.

op: REACT_UPDATE_OP,
origin: 'auto.ui.react.profiler',
startTimestamp: now,
parentSpanId: this._mountSpan.spanContext().spanId,
Copy link
Member

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, ... });

Copy link
Member Author

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

Copy link
Member Author

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?

Copy link
Member

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

@AbhiPrasad AbhiPrasad force-pushed the abhi-react-profiler-deprecate branch from fa10cf6 to ef7a534 Compare January 17, 2024 14:31
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.37 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 68.67 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.54 KB (+0.08% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.31 KB (0%)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 32.67 KB (0%)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.13 KB (0%)
@sentry/browser - Webpack (gzipped) 22.48 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 66.63 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 32.48 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.19 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 209.91 KB (0%)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 97.89 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 72.34 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 35.49 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.06 KB (0%)
@sentry/react - Webpack (gzipped) 22.52 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 85.68 KB (0%)
@sentry/nextjs Client - Webpack (gzipped) 49.81 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 17.12 KB (+0.02% 🔺)

@AbhiPrasad AbhiPrasad merged commit 68f26cc into develop Jan 18, 2024
@AbhiPrasad AbhiPrasad deleted the abhi-react-profiler-deprecate branch January 18, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants