From a85085c3ed8cf81183b50281b3a4e5aee6709ac6 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 18 Jan 2026 10:00:14 -0600 Subject: [PATCH] fix: prevent telemetry errors when Exq is not running - Check if Exq process is running before attempting to collect metrics - Change rescue to catch to handle process exits (:noproc) - Prevents error logs in environments where Exq is not configured --- lib/towerops_web/telemetry.ex | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/towerops_web/telemetry.ex b/lib/towerops_web/telemetry.ex index 3aeaa603..3ce60de7 100644 --- a/lib/towerops_web/telemetry.ex +++ b/lib/towerops_web/telemetry.ex @@ -135,12 +135,9 @@ defmodule ToweropsWeb.Telemetry do Publishes Exq queue and process statistics. """ def publish_exq_stats do - # Only run if Exq is available (not in test env) - if Application.get_env(:towerops, :env) == :test do + # Only run if Exq is available (not in test env) and the process is running + if Application.get_env(:towerops, :env) == :test or not Process.whereis(Exq) do :ok - # Get stats for each queue - - # Get process stats else try do queues = ["default", "discovery", "polling", "monitoring", "maintenance"] @@ -171,8 +168,9 @@ defmodule ToweropsWeb.Telemetry do ) :ok - rescue - _ -> :ok + catch + # Catch exits (like :noproc) and exceptions + _, _ -> :ok end end end