Aggregate DBConnection.ConnectionError in Sentry (#2260)

This commit is contained in:
Adam Rutkowski 2022-09-22 17:24:54 +02:00 committed by GitHub
parent 054f7f7dbb
commit 3f7c1ce549
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -224,7 +224,8 @@ config :sentry,
root_source_code_path: [File.cwd!()],
client: Plausible.Sentry.Client,
send_max_attempts: 1,
filter: Plausible.SentryFilter
filter: Plausible.SentryFilter,
before_send_event: {Plausible.SentryFilter, :before_send}
config :logger, Sentry.LoggerBackend,
capture_log_messages: true,

View File

@ -1,4 +1,7 @@
defmodule Plausible.SentryFilter do
@moduledoc """
Sentry callbacks for filtering and grouping events
"""
@behaviour Sentry.EventFilter
def exclude_exception?(%Sentry.CrashError{}, _source), do: true
@ -7,4 +10,16 @@ defmodule Plausible.SentryFilter do
def exclude_exception?(exception, source) do
Sentry.DefaultEventFilter.exclude_exception?(exception, source)
end
@spec before_send(Sentry.Event.t()) :: Sentry.Event.t()
def before_send(event)
# https://hexdocs.pm/sentry/readme.html#fingerprinting
def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
%{event | fingerprint: ["ecto", "db_connection", "timeout"]}
end
def before_send(event) do
event
end
end