DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
122 stars 42 forks source link

View load time #354

Closed turacma closed 1 week ago

turacma commented 1 year ago

Is your feature request related to a problem? Please describe. We recently onboarded with RUM and the DD RN SDK in our mobile app. We use react-navigation and I was noticing similar behavior to what's noted in this issue. What I'm hoping to find is a way to track load times for the various views in our app over time and identify poorly performing views to prioritize efforts for improvement.

Describe the solution you'd like A mechanism, either built into the SDK or something I can instrument myself that allows me to record initial load time of every view in my app.

Describe alternatives you've considered I tried to see if I could construct this information from the analytics view in RUM by looking at resource timing, but this includes all resources that get accessed while the user has the view open, not just the resources that we need to load the view the first time. It also doesn't seem to consider parallelism of resource fetches.

If I'm missing something obvious about RUM Analytics features and what I want is available, please let me know.

Additional context N/A

louiszawadzki commented 1 year ago

Hi @turacma, thanks for reaching out!

We currently don't provide any way to automatically track view loading time on mobile, and there's no plan to bring it in the near future as the notion of view loading time on mobile is a bit trickier than on the web.

However, we expose a DdRum.addTiming function that you can call to register timings relative to your view start time, that should be appropriate for your use case.

Once you set the timing, it is accessible as @view.custom_timings.<timing_name>. For example, if you call DdRum.addTiming('view_loaded'), it will be accessible as@view.custom_timings.view_loaded.

To visualize those timings, you need to create a facet and a measure in RUM, as explained in this documentation segment: https://docs.datadoghq.com/real_user_monitoring/explorer/search/#setup-facets-and-measures

If you need any extra help setting the monitors, please feel free to reach out to our support team that will be able to help you with it :)

louiszawadzki commented 1 year ago

Hi again, I realized I pointed to the wrong documentation link above as you need to first create a facet, then a measure. I updated the link :)

turacma commented 1 year ago

Thanks for the links @louiszawadzki. Just to confirm, will using addTiming measure from the true app start time or only from when the DataDog SDK is initialized (e.g. are you using something like this to measure start time)?

louiszawadzki commented 1 year ago

Hi @turacma,

The addTiming measure is relative to the latest Datadog view start (started by DdRum.startView, either from your code or internally if you use the @datadog/mobile-react-navigation integration), not the SDK initialization. The SDK initialization time is not used in the measure.

We also automatically report the app start time on the first view. This measurement works currently a bit differently on iOS and Android - we plan to unify the behaviour soon:

I hope this clarifies things, don't hesitate to ask more questions if needed :)