towerops/lib/towerops/error_tracker_ignorer.ex
Graham McIntire 1f9fe2ee29 chore: add gaiia library dep, remove stale honeybadger/tidewave/cbor
- Add vendored Gaiia library (path: vendor/gaiia) with auto-generated GraphQL
  queries and mutations from the Gaiia API schema
- Add startAddInventoryItemsJob + updateInventoryItem mutations
- Remove `:cbor` (was unused — no references anywhere)
- Remove stale Honeybadger filter module, tests, router plug, and config
- Remove stale Tidewave plug from endpoint (dev-only, dep already gone)
- Unlock leftover deps from lock file
2026-05-11 14:46:27 -05:00

45 lines
1.6 KiB
Elixir

defmodule Towerops.ErrorTrackerIgnorer do
@moduledoc """
Drops benign errors from ErrorTracker that occur during K8s pod shutdown
or transient DB connection cycling.
Matches the same patterns as `Towerops.LoggerFilters.drop_shutdown_errors/2`.
"""
@behaviour ErrorTracker.Ignorer
@impl true
def ignore?(%ErrorTracker.Error{reason: reason} = error, _context) do
shutdown_error?(reason) or transient_db_error?(error)
end
defp shutdown_error?(reason) when is_binary(reason) do
String.contains?(reason, "port_died") or
String.contains?(reason, "write_failed") or
String.contains?(reason, "epipe") or
String.contains?(reason, "broken pipe")
end
defp shutdown_error?(_), do: false
# Transient DB connection drops surface as DBConnection.ConnectionError. The
# Repo's aggressive idle/queue cycling (queue_target/queue_interval,
# disconnect_on_error_codes) intentionally tears down stale SSL connections,
# which can interrupt queries mid-flight. Common reasons we don't want to
# log: "connection is closed..." and "transaction rolling back". The query
# is retried by the caller; logging adds noise without value.
@transient_db_phrases [
"connection is closed",
"transaction rolling back"
]
defp transient_db_error?(%ErrorTracker.Error{reason: reason, kind: kind}) do
binary_reason = to_string(reason || "")
binary_kind = to_string(kind || "")
String.contains?(binary_kind, "DBConnection.ConnectionError") and
Enum.any?(@transient_db_phrases, &String.contains?(binary_reason, &1))
end
defp transient_db_error?(_), do: false
end