fix(telemetry): use is_nil instead of not for Process.whereis check

The `not` operator in Elixir only works with booleans, not nil values.
When Exq process doesn't exist, Process.whereis(Exq) returns nil, causing
`:badarg` error when used with `not`.

Error:
  Class=:error
  Reason=:badarg
  {:erlang, :not, [nil], [error_info: %{module: :erl_erts_errors}]}

Changed from:
  not Process.whereis(Exq)

To:
  is_nil(Process.whereis(Exq))

This properly checks if the process exists without causing runtime errors.
This commit is contained in:
Graham McIntire 2026-01-18 11:14:15 -06:00
parent bac286ee1b
commit a6a2c1cbde
No known key found for this signature in database

View file

@ -136,7 +136,7 @@ defmodule ToweropsWeb.Telemetry do
"""
def publish_exq_stats 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
if Application.get_env(:towerops, :env) == :test or is_nil(Process.whereis(Exq)) do
:ok
else
try do