Skip notifications for muted errors

This commit is contained in:
Claudio Ortolina
2026-03-10 08:22:21 +00:00
parent f86800368d
commit 8347bd04e8
2 changed files with 36 additions and 8 deletions
+14 -3
View File
@@ -28,12 +28,18 @@ defmodule ErrorTracker.ErrorNotifier do
case event_name do
[:error_tracker, :error, :new] ->
reason = truncate_reason(metadata.occurrence.reason)
{_result, new_state} = maybe_notify(metadata.occurrence, "New Error! (#{reason})", state)
{_result, new_state} =
maybe_notify(metadata.occurrence, metadata.error.muted, "New Error! (#{reason})", state)
{:noreply, new_state}
[:error_tracker, :occurrence, :new] ->
reason = truncate_reason(metadata.occurrence.reason)
{_result, new_state} = maybe_notify(metadata.occurrence, "Error: #{reason}", state)
{_result, new_state} =
maybe_notify(metadata.occurrence, metadata.error.muted, "Error: #{reason}", state)
{:noreply, new_state}
_ ->
@@ -74,7 +80,12 @@ defmodule ErrorTracker.ErrorNotifier do
)
end
defp maybe_notify(occurrence, header, state) do
defp maybe_notify(occurrence, true, _header, state) do
Logger.debug("Skipping notification for muted error #{occurrence.error_id}")
{:skipped, state}
end
defp maybe_notify(occurrence, _muted, header, state) do
error_id = occurrence.error_id
now = System.system_time(:second)
throttle_seconds = config()[:throttle_seconds] || 10