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

Missing documentation for the useProfiler hook #3408

Closed
ibesora opened this issue Apr 19, 2021 · 6 comments
Closed

Missing documentation for the useProfiler hook #3408

ibesora opened this issue Apr 19, 2021 · 6 comments

Comments

@ibesora
Copy link

ibesora commented Apr 19, 2021

Looking at this PR I found that useProfiler has been merged since June last year.
Looking at the documentation though I can't find any information about it.
Is it safe to use?

@ahartzog
Copy link

Also curious about this, and specifically inside React Native since it's re-exported inside of that?

I've implemented it in a test component and am not seeing any data coming out of it - any usage suggestions?

@AbhiPrasad
Copy link
Member

Hey - we have not documented the useProfiler yet because it has limitations compared to the Profiler HOC. We recommend using the Profiler HOC, hence why it's documented.

Once the profiler hook is in a better place, we will add documentation.

@bwittenberg
Copy link

Any plans to update the useProfiler hook? I'd prefer to use it instead of the HOC.

@louisscruz
Copy link

👋 Hey, @AbhiPrasad !

Once the profiler hook is in a better place, we will add documentation.

Is there any public discussion of the limitations? If the limitations can be addressed, maybe some contributions would be accepted to address them?

@AbhiPrasad
Copy link
Member

Hey folks, sorry for the delay on this.

I initially added the Profiler hook as an experiment while I was building out the @sentry/react package way back in 2020 (oof it's been 2 years).

At the current moment the Profiler HOC produces 3 types of spans:

  • ui.react.mount: The span that represents how long it took for the profiled component to mount.
  • ui.react.render: The span that represents how long the profiled component was on a page. This span is only generated if the profiled component mounts and unmounts while a transaction is occurring.
  • ui.react.update: The span that represents when the profiled component updated. This span is only generated if the profiled component has mounted. This is a 0 duration span as it's value comes from it's relative duration from other spans (like other components mounting or network activity).

The useProfiler hook only produces two, ui.react.mount and ui.react.render - which is why we recommend using the Profiler HOC. We should be able to add the update span - but not priority atm. PRs welcome though!

In addition, it also might be worthwhile to examine the entire premise of this profiler component in general while we do this. We've been testing using the actual React Profiler API on our frontend and it's been pretty successful. This does require folks to switch to using the profiling bundle though, so there is that.

https://github.com/getsentry/sentry/blob/db31384fa3ec3b39734a3c13de98f8842eb109bb/static/app/utils/performanceForSentry.tsx#L22-L44

@smeubank
Copy link
Member

closing issue, since as Abhi shared it was an experiment from some time back, We can re-open should there be a change in this area

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants