We're very excited to release AppSignal for Phoenix 2.1, which adds automatic instrumentation for LiveView through Telemetry. You can now receive performance and error insights for your LiveView, without manually instrumenting each of its methods.
The Old Way of Instrumenting LiveView
We added Appsignal.Phoenix.LiveView.instrument/4-5
in version 2.0.0 of the AppSignal for Phoenix integration.
In order to instrument a LiveView method, such as mount
, the helpers were used like this:
Note: Upgrading to 2.1 doesn't require any code changes. The new automatic instrumentation setup is disabled by default, you can continue to use the instrument
method as you did before.
Automatic LiveView Instrumentation
Since we released 2.0.0, the LiveView library gained instrumentation hooks through Telemetry. Instrumentation hooks allow us to gain performance and error insights without adding custom code to functions (our previous solution).
The new setup is a single call to Appsignal.Phoenix.LiveView.attach/0
to attach the LiveView Telemetry handlers.
We recommend calling this function from your app's application.ex
:
That's it!
AppSignal will now automatically instrument all mount
, handle_event
and handle_param
events, meaning you'll receive both performance and error insights into your LiveView.
This is what you could expect to see on the performance issue list in AppSignal:
Here are all the details of the first issue:
Instrumenting LiveView through Telemetry: A Community Project
This version started as a pull request by Christian Blavier, who turned his custom instrumentation into a patch for us to include in the main AppSignal for Phoenix package. Along the way, and with AJ Foster's insights, we were able to add the new setup to the already existing implementation, allowing for a clean upgrade.
Thanks for your help, Christian and AJ! 🙌
P.S. If you haven't had the chance to try AppSignal out for your Elixir project yet, this is a perfect time to do so. We also ship batches of stroopwafels wordlwide to our new users 🍪