andypearson

andypearson

Feature Request: add Telemetry events for `assign_async`

Hey all,

I have been working on some performance improvements for the Phoenix application I work on.

As part of this, through trial and error I have discovered some very slow renders happening within assign_async in some of our dashboard screens. When the screens were implemented the performance was acceptable, but as the data behind the scenes has grown the time taken to render each part of the page has increased.

At the moment we are able to profile our performance using newrelic/elixir_agent, which uses the LiveView Telemetry events to collect transaction and span data.

However, unless I am missing something, the start and end of assign_async actually completing the work is not available to Telemetry.

My request is that the following new Telemetry events are added so that it’s possible to get visibility over assign_async:

  • [:phoenix, :live_view, :assign_async, :start]
  • [:phoenix, :live_view, :assign_async, :stop]
  • [:phoenix, :live_view, :assign_async, :exception]

These follow the existing naming conventions and would allow tools like the NewRelic agent to collection the associated timings.

I must admit I’m fairly new to a lot of this, so there may be a better way of doing what I want that already existing within LiveView.

There is an associated thread on GitHub where I have been talking with one of the maintainers of the NewRelic agent which may help with additional context: Problems getting metrics on LiveView async actions · Issue #550 · newrelic/elixir_agent · GitHub

Thanks for reading!

Most Liked

steffend

steffend

Phoenix Core Team

I think the approach shown by @rhcarvalho is a good solution. I’m not against adding telemetry events, but I’m hesitant because the async operations we have are assign_async, start_async and stream_async, and adding separate events for all three feels a bit much? But if we’d only have them for handle_async, it would also feel incomplete, although it would fit to other events being tied to callbacks (mount, handle_event). So yeah, maybe explicitly wrapping when necessary is the best approach for now.

lessless

lessless

Hey Andy!

This looks like a very welcome addition. Is there a chance that an issue in the LV repo would get a better attention to the matter?

rhcarvalho

rhcarvalho

Where Next?

Popular in Proposals: Ideas Top

c4710n
This is an idea for improving the workflow of iex -S mix phx.server The Problem and The Solution in use When running multiple Phoenix en...
New
Aduril
Hello there, Whenever I setup a new project, there is a small function I always add: reply/1. What does it do? In a LiveView mount, han...
New
sodapopcan
So after complaining about this for the third or fourth time on this forum, I figured I should make a proposal. TL;DR with can be hard t...
New
markevans
Hi! I feel like Phoenix is slightly missing a trick when it comes to front-end Javascript libraries like React, Svelte, etc. I feel tha...
New
Jskalc
Hi everyone! Recently I was thinking a lot about the way HEEX renders lists. People are generally surprised about huge payloads being sen...
New
woylie
We are seeing a lot of warning logs like this: navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
eagle-head
Hi everyone, I’ve been researching Content Security Policy Level 3 support in Phoenix and wanted to share my findings and a proposal for...
New

Other popular topics Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement