browser-sdk icon indicating copy to clipboard operation
browser-sdk copied to clipboard

[RUM] Action duration in custom actions

Open roman01la opened this issue 3 years ago • 9 comments

Hello! Does DataDog's browser SDK support setting duration for a custom action? From documentation it's not clear if this is possible, also events updated in beforeSend ignore duration field in action object. It would be super useful for us to have custom actions visuailized in DataDog as a time frame (similar to network requests and long tasks), instead of a singular dot on a timeline. For now we are sending duration as a part of action's context to have at least some data, which is suboptimal, since we can't see where an action started on a timeline.

roman01la avatar Feb 05 '22 14:02 roman01la

Hello @roman01la ,

For now, it's not possible, and might not be easy to do because of the way we designed actions: we are associating other events (resources, long task, errors) to the current action, so a single action can occur at a time. So in practice, custom actions to have durations would conflict with existing click actions.

We'll keep your use-case in mind though. We'll keep you updated!

BenoitZugmeyer avatar Feb 07 '22 09:02 BenoitZugmeyer

Hey @BenoitZugmeyer have you folks revisited this case? Would be great to have durations associated to actions 🙏 Specially for debugging and tracing :)

fforres avatar Jul 27 '22 06:07 fforres

Hi @fforres,

It is still something that we have in mind but anything planned around that yet.

bcaudan avatar Jul 28 '22 11:07 bcaudan

That's great to know @bcaudan 🙏

ATM, Is there any alternative to add something with a custom duration? (With maybe addTiming, something else?)

fforres avatar Jul 28 '22 19:07 fforres

Heyo folks, reviving this old thread.

Noticed that on some of our traces, some actions showed up with a "length". Particularly actions like "Button clicked" that trigger an event, now have a duration. (As opposed to our manually tracked actions)

See: image

That action is being automatically tracked (we haven't added it as part of our rum.addAction call) . Once I look into the json attributes of it, I noticed that it has a "loading time" field.

image

Is there any way our custom added actions can leverage the same?

fforres avatar Sep 08 '22 22:09 fforres

friendly ping on the above @bcaudan @BenoitZugmeyer 🙏

fforres avatar Sep 15 '22 17:09 fforres

Hello! We don't support custom actions with duration yet. We still want to make it happen, and we already made a step in the good direction now that actions can overlap each other. But it's not there yet and we are working on other priorities.

BenoitZugmeyer avatar Sep 16 '22 13:09 BenoitZugmeyer

Hello guys, as it did not get any updates and being quite new to this, is there now any way I can transmit my own built timings to rum, through custom actions or timings. Thanks for your answer 🙏

EDIT: passing a duration value as additional context of an action and creating a "measure" from it allows me to compute stats on it.

Yooooomi avatar Oct 12 '23 08:10 Yooooomi

I was also trying to figure out how to do this today and filed a support ticket with DataDog. The solutions engineer helpfully recommended the same process as you suggested @Yooooomi, which I'll quote here in case it's useful for others as well:

I do not think there is any specific mechanism to track the performance of custom code on the real user side (if it's a separate resource). I think, in case you are interested in the performance of one particular code block, you can use context to transfer those values to Datadog.

For example,

  1. Calculate timings with custom code (JS for example);
  2. Set up those values in a global context (an example is here) or create an event with that context (context object).
  3. Create a RUM metric from that Event context (link here)

The above seems like a reasonable workaround, but it would still be neat to see this supported natively someday!

jkillian avatar Nov 17 '23 16:11 jkillian

👋 We're pleased to announce we've shipped a new kind of RUM events for this use case. Starting with v5.25.0, you can use the DD_RUM.startDurationVital or DD_RUM.addDurationVital APIs to report "Vital" events with durations to Datadog. See documentation.

Please note that the UI for this feature will be rolled out progerssively during the week.

Any feedback is welcome!

BenoitZugmeyer avatar Sep 02 '24 08:09 BenoitZugmeyer