From be1ebdc035ab1a39b3d64ca2f4dea20d084f87dc Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 8 May 2026 10:40:45 -0500 Subject: [PATCH] test: gate Oban queue-depth poller on :start_telemetry_poller flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MicrowavepropWeb.Telemetry's :telemetry_poller fires dispatch_oban_queue_depth/0 every 30 s. In test env it runs outside any Ecto sandbox owner, so its `Repo.all` against oban_jobs holds a pool connection long enough to starve LiveView `render_async` tests with 100 ms async windows — repro'd as flaky SkewtLive failures. Same shape as the PromEx Oban plugin we already disable in test via :prom_ex_include_oban_plugin. Add :start_telemetry_poller (defaults to true) and toggle it off in config/test.exs. Production keeps the 30-second per-(queue,state) gauge. --- config/test.exs | 7 +++++++ lib/microwaveprop_web/telemetry.ex | 22 +++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config/test.exs b/config/test.exs index 36cd48fc..8aad59e8 100644 --- a/config/test.exs +++ b/config/test.exs @@ -113,6 +113,13 @@ config :microwaveprop, nexrad_req_options: [plug: {Req.Test, Microwaveprop.Weath config :microwaveprop, solar_req_options: [plug: {Req.Test, Microwaveprop.Weather.SolarClient}] config :microwaveprop, srtm_req_options: [plug: {Req.Test, Microwaveprop.Terrain.Srtm}, retry: false] config :microwaveprop, start_freshness_monitor: false + +# The Oban queue-depth poller (`MicrowavepropWeb.Telemetry`) runs every +# 30 s outside any sandbox owner. Its query against `oban_jobs` holds a +# pool connection long enough to race LiveView `start_async` tests with +# 100 ms async windows (e.g. SkewtLive). Off in tests; the same +# poll-once-per-pod metric is irrelevant inside a single-process suite. +config :microwaveprop, start_telemetry_poller: false config :microwaveprop, swpc_req_options: [plug: {Req.Test, Microwaveprop.SpaceWeather.SwpcClient}, retry: false] config :microwaveprop, uwyo_req_options: [plug: {Req.Test, Microwaveprop.Weather.UwyoSoundingClient}, retry: false] diff --git a/lib/microwaveprop_web/telemetry.ex b/lib/microwaveprop_web/telemetry.ex index f53615bb..38493f05 100644 --- a/lib/microwaveprop_web/telemetry.ex +++ b/lib/microwaveprop_web/telemetry.ex @@ -10,15 +10,19 @@ defmodule MicrowavepropWeb.Telemetry do @impl true def init(_arg) do - children = [ - # Oban queue-depth is the only poller measurement and each replica - # issues the same GROUP-BY over oban_jobs. 30s gives enough fidelity - # for dashboard trends without burning ~3/min of identical queries - # per extra replica. - {:telemetry_poller, measurements: periodic_measurements(), period: 30_000} - # Add reporters as children of your supervision tree. - # {Telemetry.Metrics.ConsoleReporter, metrics: metrics()} - ] + # Oban queue-depth is the only poller measurement and each replica + # issues the same GROUP-BY over oban_jobs. 30s gives enough fidelity + # for dashboard trends without burning ~3/min of identical queries + # per extra replica. Skipped in test (no sandbox owner → connection + # contention with LiveView async tests; identical pattern to the + # PromEx Oban plugin we already disable via + # `:prom_ex_include_oban_plugin`). + children = + if Application.get_env(:microwaveprop, :start_telemetry_poller, true) do + [{:telemetry_poller, measurements: periodic_measurements(), period: 30_000}] + else + [] + end Supervisor.init(children, strategy: :one_for_one) end