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
This commit is contained in:
parent
9b613f7a40
commit
a85085c3ed
1 changed files with 5 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue