Skip to content

Commit

Permalink
Ignore excess logger errors from Cowboy when sending to Sentry (#5096)
Browse files Browse the repository at this point in the history
* Ignore excess logger errors from Cowboy when sending to Sentry

* Add test and simplify
  • Loading branch information
zoldar authored Feb 19, 2025
1 parent 482ba1f commit 0e356c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/sentry_filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions test/plausible/sentry_filter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0e356c1

Please sign in to comment.