LiveView emits comprehensive telemetry events throughout its lifecycle, allowing you to monitor performance, track errors, and gather metrics.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phoenixframework/phoenix_live_view/llms.txt
Use this file to discover all available pages before exploring further.
Event Overview
LiveView emits telemetry events for:- LiveView lifecycle callbacks (mount, handle_params, handle_event, render)
- LiveComponent lifecycle callbacks (update, handle_event)
- Component destruction
:start, :stop, and :exception.
LiveView Events
Mount Events
[:phoenix, :live_view, :mount, :start]
Dispatched immediately before mount/3 is invoked.
Measurement:
[:phoenix, :live_view, :mount, :stop]
Dispatched when mount/3 completes successfully.
Measurement:
[:phoenix, :live_view, :mount, :exception]
Dispatched when an exception is raised in mount/3.
Measurement:
Handle Params Events
[:phoenix, :live_view, :handle_params, :start]
Dispatched immediately before handle_params/3 is invoked.
Measurement:
[:phoenix, :live_view, :handle_params, :stop]
Dispatched when handle_params/3 completes successfully.
Measurement:
[:phoenix, :live_view, :handle_params, :exception]
Dispatched when an exception is raised in handle_params/3.
Metadata includes: kind, reason, and other standard fields.
Handle Event Events
[:phoenix, :live_view, :handle_event, :start]
Dispatched immediately before handle_event/3 is invoked.
Metadata:
[:phoenix, :live_view, :handle_event, :stop]
Dispatched when handle_event/3 completes successfully.
[:phoenix, :live_view, :handle_event, :exception]
Dispatched when an exception is raised in handle_event/3.
Render Events
[:phoenix, :live_view, :render, :start]
Dispatched immediately before render/1 is invoked.
Metadata:
[:phoenix, :live_view, :render, :stop]
Dispatched when render/1 completes successfully.
Measurement:
[:phoenix, :live_view, :render, :exception]
Dispatched when an exception is raised in render/1.
LiveComponent Events
Update Events
[:phoenix, :live_component, :update, :start]
Dispatched immediately before update/2 or update_many/1 is invoked.
Metadata:
For
update/2, this might dispatch one event for multiple calls.[:phoenix, :live_component, :update, :stop]
Dispatched when update/2 or update_many/1 completes successfully.
Metadata:
sockets metadata contains the updated sockets.
[:phoenix, :live_component, :update, :exception]
Dispatched when an exception is raised in update/2 or update_many/1.
Handle Event Events
[:phoenix, :live_component, :handle_event, :start]
Dispatched immediately before handle_event/3 is invoked on a component.
Metadata:
[:phoenix, :live_component, :handle_event, :stop]
Dispatched when component handle_event/3 completes successfully.
[:phoenix, :live_component, :handle_event, :exception]
Dispatched when an exception is raised in component handle_event/3.
Destroyed Event
[:phoenix, :live_component, :destroyed]
Dispatched after a LiveComponent is destroyed. No measurement.
Metadata:
Setting Up Telemetry
Basic Telemetry Handler
Attach a handler in your application start:Handler Implementation
Common Use Cases
Performance Monitoring
Track slow LiveView operations:Error Tracking
Send exceptions to external monitoring services:Metrics Collection
Collect metrics with Telemetry.Metrics:Adding Custom Tags
Extract useful information for grouping:Integration with Monitoring Services
AppSignal
Prometheus
StatsD
Best Practices
- Filter events: Only attach handlers for events you need
- Use tags: Add meaningful tags to group and filter metrics
- Monitor performance: Track mount, event, and render durations
- Track exceptions: Send errors to monitoring services
- Set thresholds: Alert on slow operations or high error rates
- Use Telemetry.Metrics: For standardized metric definitions
- Test handlers: Ensure telemetry handlers don’t crash
- Keep handlers fast: Don’t block the LiveView process