fix(portal): Attach Sentry in each umbrella app (#8749)

- Attaches the Sentry Logging hook in each of [api, web, domain]
- Removes errant Sentry logging configuration in config/config.exs
- Fixes the exception logger to default to logging exceptions, use
`skip_sentry: true` to skip

Tested successfully in dev. Hopefully the cluster behaves the same way.

Fixes #8639
This commit is contained in:
Jamil
2025-04-10 21:17:12 -07:00
committed by GitHub
parent 8b08be15b3
commit d2fd57a3b6
6 changed files with 24 additions and 17 deletions

View File

@@ -6,6 +6,15 @@ defmodule API.Application do
_ = :opentelemetry_cowboy.setup()
_ = OpentelemetryPhoenix.setup(adapter: :cowboy2)
# Configure Sentry to capture Logger messages
:logger.add_handler(:sentry, Sentry.LoggerHandler, %{
config: %{
level: :warning,
metadata: :all,
capture_log_messages: true
}
})
children = [
API.Endpoint,
API.RateLimit

View File

@@ -1,9 +1,9 @@
defmodule Domain.Telemetry.Sentry do
def before_send(%{original_exception: %{report_to_sentry: report_to_sentry}} = event) do
if report_to_sentry do
event
else
def before_send(%{original_exception: %{skip_sentry: skip_sentry}} = event) do
if skip_sentry do
nil
else
event
end
end

View File

@@ -7,6 +7,15 @@ defmodule Web.Application do
_ = :opentelemetry_cowboy.setup()
_ = OpentelemetryPhoenix.setup(adapter: :cowboy2)
# Configure Sentry to capture Logger messages
:logger.add_handler(:sentry, Sentry.LoggerHandler, %{
config: %{
level: :warning,
metadata: :all,
capture_log_messages: true
}
})
children = [
Web.Endpoint
]

View File

@@ -25,7 +25,7 @@ defmodule Web.SignIn do
{:ok, socket}
else
_other ->
raise Web.LiveErrors.NotFoundError, report_to_sentry: false
raise Web.LiveErrors.NotFoundError, skip_sentry: true
end
end

View File

@@ -1,6 +1,6 @@
defmodule Web.LiveErrors do
defmodule NotFoundError do
defexception message: "Not Found", report_to_sentry: true
defexception message: "Not Found", skip_sentry: false
defimpl Plug.Exception do
def status(_exception), do: 404

View File

@@ -168,17 +168,6 @@ config :web, api_url_override: "ws://localhost:13001/"
##### API #####################
###############################
config :api, :logger, [
{:handler, :api, Sentry.LoggerHandler,
%{
config: %{
level: :warning,
metadata: :all,
capture_log_messages: true
}
}}
]
config :api, ecto_repos: [Domain.Repo]
config :api, generators: [binary_id: true, context_app: :domain]