Ignore excess logger errors from Cowboy when sending to Sentry (#5096)

* Ignore excess logger errors from Cowboy when sending to Sentry

* Add test and simplify
This commit is contained in:
Adrian Gruntkowski 2025-02-19 14:39:06 +01:00 committed by GitHub
parent 482ba1face
commit 0e356c14f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -23,6 +23,14 @@ defmodule Plausible.SentryFilter 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

View File

@ -12,4 +12,25 @@ defmodule Plausible.SentryFilterTest do
assert %Sentry.Event{fingerprint: ["ingestion_request"]} =
Plausible.SentryFilter.before_send(event)
end
test "ignores excess cowboy error messages" do
event = %Sentry.Event{
event_id: "5f0a9f9b04df4050884966c87a4e62b8",
timestamp: "2025-02-19T13:23:05.705493",
extra: %{logger_level: :error, logger_metadata: %{}},
level: :error,
logger: nil,
message: %Sentry.Interfaces.Message{
message: nil,
params: nil,
formatted:
"Ranch listener PlausibleWeb.Endpoint.HTTP, connection process #PID<0.1216.0>, " <>
"stream 1 had its request process #PID<0.1217.0> exit with " <>
"reason {{{%Plug.Parsers.ParseError{\n ..."
},
source: :logger
}
assert Plausible.SentryFilter.before_send(event) == false
end
end