-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsentry_filter.ex
More file actions
69 lines (59 loc) · 1.93 KB
/
Copy pathsentry_filter.ex
File metadata and controls
69 lines (59 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
defmodule Plausible.SentryFilter do
@moduledoc """
Sentry callbacks for filtering and grouping events
"""
@spec before_send(Sentry.Event.t()) :: Sentry.Event.t()
def before_send(event)
def before_send(%{original_exception: %Bamboo.PostmarkAdapter.Error{} = e} = event) do
if Bamboo.PostmarkAdapter.Error.is_hard_bounce(e), do: false, else: event
end
def before_send(%{original_exception: %Phoenix.NotAcceptableError{}}), do: false
def before_send(%{original_exception: %Plug.CSRFProtection.InvalidCSRFTokenError{}}), do: false
def before_send(%{original_exception: %Plug.Static.InvalidPathError{}}), do: false
def before_send(
%{
exception: [%{type: "DBConnection.ConnectionError"}],
original_exception: %{reason: reason}
} = event
) do
%{event | fingerprint: ["db_connection", reason]}
end
def before_send(
%{
exception: [%{type: "Mint.TransportError"}],
original_exception: %{reason: reason}
} = event
) do
%{event | fingerprint: ["mint_transport", reason]}
end
def before_send(
%{
exception: [%{type: "Finch.TransportError"}],
original_exception: %{reason: reason}
} = event
) do
%{event | fingerprint: ["mint_transport", reason]}
end
def before_send(
%{source: :logger, message: %{formatted: "Ch.Connection (#PID<" <> rest}} = event
) do
if String.ends_with?(rest, ")) disconnected: ** (Mint.HTTPError) the connection is closed") do
false
else
event
end
end
def before_send(%{extra: %{request: %Plausible.Ingestion.Request{}}} = event) do
%{event | fingerprint: ["ingestion_request"]}
end
def before_send(%{source: :logger, message: %{formatted: "Ranch listener" <> rest}} = event) do
if String.contains?(rest, "had its request process") do
false
else
event
end
end
def before_send(event) do
event
end
end