PropertyDamage.Telemetry.Dashboard (PropertyDamage v0.2.0)

View Source

LiveView dashboard for monitoring PropertyDamage test runs.

This module provides a real-time dashboard that displays:

  • Run progress and statistics
  • Command execution metrics
  • Check pass/fail rates
  • Shrinking progress
  • Recent events timeline

Setup

1. Create a LiveView in your application

defmodule MyAppWeb.PropertyDamageDashboardLive do
  use MyAppWeb, :live_view

  alias PropertyDamage.Telemetry.{Collector, Dashboard}

  def mount(_params, _session, socket) do
    if connected?(socket) do
      Collector.subscribe()
    end

    state = Collector.get_state()

    {:ok,
     assign(socket,
       page_title: "PropertyDamage Dashboard",
       state: state,
       view_mode: :overview
     )}
  end

  def handle_info({:telemetry_update, _event_type, _data, state}, socket) do
    {:noreply, assign(socket, :state, state)}
  end

  def handle_event("reset", _params, socket) do
    Collector.reset()
    {:noreply, socket}
  end

  def handle_event("set_view_mode", %{"mode" => mode}, socket) do
    {:noreply, assign(socket, :view_mode, String.to_existing_atom(mode))}
  end

  def render(assigns) do
    Dashboard.render(assigns)
  end
end

2. Add route in your router

live "/property-damage", PropertyDamageDashboardLive

3. Start the collector in your application

# In your application.ex
children = [
  # ...
  PropertyDamage.Telemetry.Collector
]

Requirements

  • Phoenix LiveView must be installed in your application
  • The Collector must be running to receive events

Summary

Functions

Returns the CSS styles for the dashboard.

Returns the initial assigns for the dashboard.

Render the dashboard HTML.

Functions

css()

@spec css() :: String.t()

Returns the CSS styles for the dashboard.

initial_assigns()

@spec initial_assigns() :: keyword()

Returns the initial assigns for the dashboard.

render(assigns)

@spec render(map() | keyword()) :: String.t()

Render the dashboard HTML.

Returns a Phoenix.LiveView.Rendered struct if Phoenix is available, otherwise returns an HTML string.