sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Missing documentation for the useProfiler hook

Open ibesora opened this issue 4 years ago • 5 comments

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?

ibesora avatar Apr 19 '21 05:04 ibesora

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?

ahartzog avatar Sep 22 '21 16:09 ahartzog

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.

AbhiPrasad avatar Oct 04 '21 14:10 AbhiPrasad

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

bwittenberg avatar May 31 '22 19:05 bwittenberg

👋 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?

louisscruz avatar Jul 12 '22 02:07 louisscruz

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

AbhiPrasad avatar Jul 12 '22 13:07 AbhiPrasad

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

smeubank avatar Dec 30 '22 14:12 smeubank