Phoenix_live_view: Execute LiveView telemetry events

Created on 3 Mar 2020  路  6Comments  路  Source: phoenixframework/phoenix_live_view

I'm opening this issue to discuss what :telemetry events, if any, we should emit from a LiveView.

Some Phoenix events are executed as usual for a LiveView:

  • [:phoenix, :endpoint, :start]
  • [:phoenix, :endpoint, :stop]
  • [:phoenix, :socket_connected]
  • ~[:phoenix, :channel_joined]~

What other events should we be executing for LiveView, specifically? Here are some I considered:

  • [:phoenix, :live_view, :mount] <-- is this a start?

  • [:phoenix, :live_view, :terminate] <-- this is a stop?

  • [:phoenix, :live_view, :redirect] <-- is this helpful?

enhancement

Most helpful comment

Thanks to @leandrocp for pointing me to this issue--I'm also curious to hear what ya'll think about instrumenting handle_event similarly to how Plug.Telemetry emits the [*, *, :stop] event to allow for easy request duration tracking. Just as it's helpful to visualize request duration for HTTP requests, it could be a useful to visualize slow LiveView events in live dashboard and elsewhere.

All 6 comments

@mcrumm are you sure channel_joined is called for LiveViews? socket_connected is though.

About the new events, I would start from which events people want to know more about in the logs. I think instrumenting mount is a good start. I would also instrument handle_params in isolation whenever it is called (as it implies page navigation) - that would probably be close to the redirect that you mentioned. terminate is tricky, as it is only invoked if trapping exits and we likely don't want to impose trapping exits. So I would skip it for now.

What about handle_event? Instrumenting called events would allow to measure it, in other words, see what's happening while the process is alive, which would help tools like live_dashboard and others to present slow events and metrics like that. Is that possible?

Thanks to @leandrocp for pointing me to this issue--I'm also curious to hear what ya'll think about instrumenting handle_event similarly to how Plug.Telemetry emits the [*, *, :stop] event to allow for easy request duration tracking. Just as it's helpful to visualize request duration for HTTP requests, it could be a useful to visualize slow LiveView events in live dashboard and elsewhere.

Hi @SophieDeBenedetto and @leandrocp!

I've been focused on some other telemetry-relates things, but I certainly haven't forgotten about this :)

Hey @mcrumm good to know, thanks. And let me know if you need any kind of help :)

Closing in favor of #983.

Was this page helpful?
0 / 5 - 0 ratings