defmodule ElixirDashboardWeb.PerformanceLive.Endpoints do @moduledoc """ Demo app wrapper - delegates to the library LiveView. """ use ElixirDashboardWeb, :live_view alias ElixirDashboard.PerformanceMonitor.Store @impl true def mount(_params, _session, socket) do if connected?(socket) do # Refresh data every 5 seconds :timer.send_interval(5000, self(), :refresh) end endpoints = Store.get_slow_endpoints() {:ok, assign(socket, :endpoints, endpoints)} end @impl true def handle_info(:refresh, socket) do endpoints = Store.get_slow_endpoints() {:noreply, assign(socket, :endpoints, endpoints)} end @impl true def handle_event("clear", _params, socket) do Store.clear_all() {:noreply, assign(socket, :endpoints, [])} end @impl true def render(assigns) do ~H"""
Showing the 100 slowest endpoints recorded since the server started (threshold: 100ms).
No slow endpoints recorded yet. Start making requests to see data.
| Duration (ms) | Endpoint Path | Recorded At |
|---|---|---|
| <%= endpoint.duration_ms %>ms | <%= endpoint.path %> | <%= format_timestamp(endpoint.timestamp) %> |