defmodule Aprsme.PromEx do
  @moduledoc """
  PromEx supervision module for the aprs.me application.

  Built-in plugins provide metrics for Phoenix, Phoenix LiveView, Ecto, the BEAM
  VM, and the Application/release. The custom `Aprsme.PromEx.Plugins.Aprsme`
  plugin exposes the app-specific telemetry events emitted by the GenStage
  packet pipeline, SpatialPubSub, and the periodic Postgres collectors.

  Metrics are scraped at `GET /metrics` on the Phoenix endpoint via
  `PromEx.Plug` (mounted in the router).
  """

  use PromEx, otp_app: :aprsme

  alias PromEx.Plugins

  @impl true
  def plugins do
    [
      Plugins.Application,
      Plugins.Beam,
      {Plugins.Phoenix, router: AprsmeWeb.Router, endpoint: AprsmeWeb.Endpoint},
      Plugins.PhoenixLiveView,
      {Plugins.Ecto, otp_app: :aprsme, repos: [Aprsme.Repo]},
      Aprsme.PromEx.Plugins.Aprsme
    ]
  end

  @impl true
  def dashboard_assigns do
    [
      datasource_id: "Prometheus",
      default_selected_interval: "30s"
    ]
  end

  @impl true
  def dashboards do
    []
  end
end
